feat(nimbus): create new results page overview section#13777
feat(nimbus): create new results page overview section#13777moibra05 merged 7 commits intomozilla:mainfrom
Conversation
SUMMARY: SUCCESS: fenix at main (cb654cdfed4b286be84a80d8950f5382ac4c106f) version None fenix at main (cb654cdfed4b286be84a80d8950f5382ac4c106f) version 146.0.0 firefox_ios at main (f6a8b86c9ff1422ca4b82fdc94a38b850380b27c) version None firefox_ios at main (f6a8b86c9ff1422ca4b82fdc94a38b850380b27c) version 144.2.0 focus_android at main (fe8a71cd70ad5674abe1824fe11dc78372b736c2) version None focus_ios at main (f6a8b86c9ff1422ca4b82fdc94a38b850380b27c) version None focus_ios at main (f6a8b86c9ff1422ca4b82fdc94a38b850380b27c) version 144.2.0 monitor_cirrus at main (eed2d7fcddb3a54c83e0d160e17872f8ed23ef46) version None mozillavpn_backend_cirrus at main (fcb86c1400032f9101f99f373cdf70526c890bff) version None firefox_accounts_cirrus at main (b00fa486b84e63aa4e2352b40c5a5d691273c532) version None firefox_desktop at main (cb654cdfed4b286be84a80d8950f5382ac4c106f) version None firefox_desktop at main (cb654cdfed4b286be84a80d8950f5382ac4c106f) version 146.0.0 CACHED: fenix at beta (5b8638fe4248185581fceec7c0e256ad482f18ca) version 145.0.0 (cached) fenix at release (d5105f31e14d19e34e7b04f7580d6507ab27ba5d) version 144.0.1 (cached) firefox_ios at release/v140 (00831cb025b21d305a63727850f511461d38d8fd) version 140.4.0 (cached) firefox_ios at release/v141 (69430564a07de646d13a5337c5bfc1a5a576da13) version 141.3.0 (cached) firefox_ios at release/v142 (9d2a88be39b477f39cf753c69adaef4006d603ae) version 142.0.2 (cached) firefox_ios at release/v142.1 (7760fd164fda9ab5137f7cd986e52c643a943f28) version 142.1.1 (cached) firefox_ios at release/v143.0 (269bd144cce81315988c106ab5a8388eee877a01) version 143.0.2 (cached) firefox_ios at release/v143.1 (75667e1377ab023b1ecde7bc3f396a0c52ad95a4) version 143.1.2 (cached) firefox_ios at release/v143.2 (68f062a220f5a7e2677094ca7a967ccd2e6b4669) version 143.2.1 (cached) firefox_ios at release/v144.0 (1dcfbc5b85c1d85170e67ee88813de22a398e27f) version 144.0.1 (cached) firefox_ios at release/v144.1 (a8fc6431d0321da5a007bac9632a8cf7fccbf863) version 144.1.0 (cached) firefox_ios at firefox-v144.0 (15b7783a0dad7ca915da57e03b5cda27fd076669) version 144.0.0 (cached) firefox_ios at firefox-v143.2 (5fbea8adc2a31f1117d23358fc63f433c606e2ec) version 143.2.0 (cached) firefox_ios at firefox-v143.1 (8c448014c4ae914b498cc3eed9711ac7c427ea48) version 143.1.0 (cached) firefox_ios at firefox-v143.0 (6b1e8d6e411786bd05cbc8a278df529494e4b9fb) version 143.0.0 (cached) firefox_ios at firefox-v142.1 (800347c19d5917a54d00c0ce94d17bc7d37df92b) version 142.1.0 (cached) firefox_ios at firefox-v142.0 (fda95e1815322d9f1563d575bc1abb79d81041ab) version 142.0.0 (cached) firefox_ios at firefox-v141.2 (a546df46d992dd7e793f18c551a70226205be5ab) version 141.2.0 (cached) firefox_ios at firefox-v141.1 (417533fb96c0fdda08ff2b300baaa507c2c02551) version 141.1.0 (cached) firefox_ios at firefox-v141.0 (bc01aac74d614b21cad10df0ca574b9c308cad6d) version 141.0.0 (cached) firefox_ios at firefox-v140.3 (b97fc73ef2df468c2c020013a2a7369f6e3fbb68) version 140.3.0 (cached) firefox_ios at firefox-v140.2 (e06518a809c6c98bf70147de1be100f597998473) version 140.2.0 (cached) firefox_ios at firefox-v140.1 (9ac126051d295037e061346535867992b11dc5dc) version 140.1.0 (cached) firefox_ios at firefox-v140.0 (9271e4103dac70d2b201346126a31a0300c59709) version 140.0.0 (cached) focus_android at releases_v121 (979fbe8d7fe04a9b09fe657bb787fda6f4d5ab42) version 121.1.1 (cached) focus_android at releases_v122 (1fcbfc41dba53965481a0e4d4725833bf3669dce) version 122.1.1 (cached) focus_android at releases_v123 (5a38e0cb4499f659a5fff308fa1deee653c0318b) version 123.1.1 (cached) focus_android at releases_v124 (0ad8d97fb3ab2ec6b9bb3905ee742900a4b9325d) version 124.2.1 (cached) focus_android at releases_v125 (2b43ab8069abac2bfee4b609e734c0207876a2ac) version 125.3.1 (cached) focus_android at focus-v125.3.0 (9f2990415376f169eb0053fceb329b70b4421bcb) version 125.3.0 (cached) focus_android at focus-v125.2.0 (d1c6eeb4167fc8ffed02cdfd3138fa696381d548) version 125.2.0 (cached) focus_android at main (fe8a71cd70ad5674abe1824fe11dc78372b736c2) version 125.0.0 (cached) focus_android at focus-v124.2.0 (7a0e399c7bc4faae43ce70ddc201c7899498d1b5) version 124.2.0 (cached) focus_android at focus-v124.1.0 (516df33ca96e950af1bf791893cd16d7add61c5d) version 124.1.0 (cached) focus_android at focus-v124.0 (5afe87a5bbb92f7ecf990a2fbc8095503a47c272) version 124.0.0 (cached) focus_android at focus-v123.1.0 (cb7c807e0fb5bc08131415e2e5ecef9da658d410) version 123.1.0 (cached) focus_android at focus-v123.0 (f5f378e2c05c9d69a5088c112c14fdea507d1c65) version 123.0.0 (cached) focus_android at focus-v122.1.0 (0d665405685c43c9266a3de65f16eabb832bb908) version 122.1.0 (cached) focus_android at focus-v122.0.1 (c67c9e840c00ec348a6a27adedad28feb54aa4a2) version 122.0.1 (cached) focus_android at focus-v122.0 (b49c4f23804d23cc727b8f70c061dccd64d720bc) version 122.0.0 (cached) focus_android at focus-v121.1.0 (62d5117f7996cc8862fdbdc0cb4a1dd5cdebedd6) version 121.1.0 (cached) focus_android at focus-v121.0.1 (fd4d2513324712e91577d8be18797e64089d3cf1) version 121.0.1 (cached) focus_android at focus-v121.0 (1955f8455fa2cac1b2080af9360996c06df5b4dd) version 121.0.0 (cached) focus_ios at release/v138 (178f4e6c30adce3c6e04239de359bb00c1a5d94b) version 138.4.0 (cached) focus_ios at release/v139 (0fc3b6546731da1c75fcbf06d7580ba6c64fab42) version 139.3.0 (cached) focus_ios at release/v140 (00831cb025b21d305a63727850f511461d38d8fd) version 140.4.0 (cached) focus_ios at release/v141 (69430564a07de646d13a5337c5bfc1a5a576da13) version 141.3.0 (cached) focus_ios at release/v142 (9d2a88be39b477f39cf753c69adaef4006d603ae) version 142.0.2 (cached) focus_ios at focus/klar-v143.0 (72645ad484df1c240e64871aa5408b296d94798c) version 143.0.0 (cached) focus_ios at focus/klar-v141.0 (2d2a8b3fcd4a112fa6e387d687138dc662d96e37) version 141.0.0 (cached) focus_ios at focus/klar-v140.0 (2d3684ce1d30402082a7d37b3df58e0c672ac4ab) version 140.0.0 (cached) focus_ios at focus/klar-v139.0 (0a40db672ac6d422377ae4394dcbaae878998e9e) version 139.0.0 (cached) focus_ios at focus/klar-v138.0 (33f7f00718adf88505d1804ccedb56750b04f2fb) version 138.0.0 (cached) firefox_desktop at beta (5b8638fe4248185581fceec7c0e256ad482f18ca) version 145.0.0 (cached) firefox_desktop at release (d5105f31e14d19e34e7b04f7580d6507ab27ba5d) version 144.0.1 (cached) firefox_desktop at esr115 (72c8456c33b883032eabdce7ba76def84e25ddb4) version 115.30.0 (cached) firefox_desktop at esr128 (ed38f9209e39bd7ad247c81a7c20c99c874e0a62) version 128.14.1 (cached) firefox_desktop at esr140 (edd34d92c007bd3acfb3eab74fee1f004ae01ed2) version 140.5.0 (cached) Circle CI Task: https://circleci.com/gh/mozilla/experimenter/381310 Co-authored-by: Experimenter CircleCI Bot <experimenter-ci-bot@mozilla.com>
e3f7533 to
e4d7a58
Compare
|
@moibra05 I will review it once it is ready, but the screenshot you provided, results page is looking good, can't wait to see once this is finished |
|
Wow wow wow! Look at it go! |
| @property | ||
| def has_exposures(self): | ||
| # True if there are any exposures in the results data | ||
| if self.results_data and "v3" in self.results_data: | ||
| results_data = self.results_data["v3"] | ||
| for window in ["overall", "weekly"]: | ||
| if results_data.get(window): | ||
| exposure_data = results_data[window].get("exposures", {}).get("all") | ||
| if exposure_data is not None: | ||
| return True | ||
|
|
||
| return False |
|
This is all coming along great, looks great. I'd say this could've been done as several PRs, one just to land the skeleton of the page, and then the parts about looking up exposures, the parts about number formatting, etc could've all been their own little PRs. No reason to change this, but as you keep working on it think of things like that all as their own littler changes, easier to review, faster to land. Edit: I didn't realize this included another PR in it, but still good to think about when things can be split up even more 👍 |
| @register.filter | ||
| def short_number(value, precision=1): | ||
| try: | ||
| n = int(value) | ||
| except (TypeError, ValueError): | ||
| return value | ||
|
|
||
| n = abs(n) | ||
|
|
||
| if n < 1000: | ||
| return f"{n}" | ||
| if n < 1_000_000: | ||
| v = n / 1000.0 | ||
| if v.is_integer(): | ||
| return f"{int(v)}k" | ||
| return f"{v:.{int(precision)}f}k" | ||
| v = n / 1_000_000.0 | ||
| if v.is_integer(): | ||
| return f"{int(v)}M" | ||
| return f"{v:.{int(precision)}f}M" |
There was a problem hiding this comment.
There's gotta be a library or something for this.. right??
There was a problem hiding this comment.
i found this although i think it might be a bit overkill
There was a problem hiding this comment.
What do you mean by overkill? Usually better to use a well supported library than do stuff manually when possible.
There was a problem hiding this comment.
I've always thought that if something seems simple enough to write myself, relying on a library would be excessive. Another learning opportunity for me lol
There was a problem hiding this comment.
@moibra05 Every line of code written is a line that has to be maintained. Every line has a cost. Less line better 🙏
There was a problem hiding this comment.
There is always a trade off because on the other end of the spectrum you end up in NPM left-pad hell and you pull in 10s to 100s of packages for what is a 10 line function. But on the other end you have problems that appear easy (like dates and times) that should really be outsourced to people who think about that stuff all day (relevant xkcd)
51300a3 to
72ca725
Compare
| branches = [] | ||
|
|
||
| if self.reference_branch: | ||
| branches.append(self.reference_branch) | ||
| branches.extend(self.treatment_branches) | ||
|
|
||
| for branch in branches: |
There was a problem hiding this comment.
branch iteration order doesn't seem to matter here so we can:
| branches = [] | |
| if self.reference_branch: | |
| branches.append(self.reference_branch) | |
| branches.extend(self.treatment_branches) | |
| for branch in branches: | |
| for branch in self.branches.all(): |
We should probably prefetch the screenshot FK relationship:
self.branches.all().prefetch_related("screenshots")
otherwise we do N + 1 queries instead of 2
There was a problem hiding this comment.
the order is important here since it defines how the branch cards are displayed which make the most sense having the control branch be first

Because
This commit
Fixes #13734