Simplify and add tests

Makes these assumptions:
- we don’t care about history before 29th November 2019 at 11am (this
  is when priority started to mean a proportion rather than a ranking)
- the priority of the second provider will always be the inverse of
  the first provider

Which means the code is a lot simpler/actually does what you’d expect.
This commit is contained in:
Chris Hill-Scott
2019-12-03 17:54:57 +00:00
parent 5233ee4bd9
commit 8122fa1d5d
3 changed files with 174 additions and 57 deletions

View File

@@ -24,10 +24,10 @@
<div class="column-two-thirds">
<div class="history-list-percentage-without-border">
<div class="history-list-percentage-left-label">
MMG
{{ primary_provider }}
</div>
<div class="history-list-percentage-right-label">
Firetext
{{ secondary_provider }}
</div>
{% call form_wrapper() %}
<div class="radio-slider" data-module="radio-slider">
@@ -71,17 +71,16 @@
{% endif %}
</div>
<div class="column-two-thirds">
{% set percentage = (version.priority / (version.priority + version.other_provider.priority) * 100) %}
<div class="history-list-percentage">
<div class="history-list-percentage-left-label">
{{ version.display_name }}<br><br>
{{ percentage|format_thousands }}%
{{ primary_provider }}<br><br>
{{ version.priority|format_thousands }}%
</div>
<div class="history-list-percentage-right-label">
{{ version.other_provider.display_name }}<br><br>
{{ (100 - percentage)|format_thousands }}%
{{ secondary_provider }}<br><br>
{{ (100 - version.priority)|format_thousands }}%
</div>
<div class="history-list-percentage-marker" style="left: {{ (100 -percentage)|format_thousands }}%"></div>
<div class="history-list-percentage-marker" style="left: {{ (100 -version.priority)|format_thousands }}%"></div>
</div>
</div>
</div>