BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bonus-stats.twig 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {% macro user(list, index) %}
  2. {% if list[index] is defined %}{{ list[index].user_id|user_url }}{% else %} {% endif %}
  3. {% endmacro %}
  4. {% macro total(list, index) %}
  5. {% if list[index] is defined %}{{ list[index].total|number_format }}{% else %} {% endif %}
  6. {% endmacro %}
  7. {% macro accrual(d) %}
  8. {% if d is defined %}{{ d.total|number_format }}{% else %}—{% endif %}
  9. {% endmacro %}
  10. {% macro delta(interval, n) %}
  11. {% set p = n - 1 %}
  12. {% if interval[n] is defined and interval[p] is defined %}{{ (interval[p].total - interval[n].total)|number_format }}
  13. {% elseif interval[n] is defined %}{{ interval[n].total|number_format }}
  14. {% elseif interval[p] is defined %}{{ -interval[p].total|number_format }}
  15. {% else %}—{% endif %}
  16. {% endmacro %}
  17. {% set max = 6 %}
  18. <div class="pad box">
  19. <h2>Accrual</h2>
  20. <table>
  21. <tr class="colhead">
  22. <td>Interval</td>
  23. <td>Current</td>
  24. {% for n in range(1, max) %}
  25. <td>&Delta; n-{{ n }}</td>
  26. {% endfor %}
  27. </tr>
  28. <tr class="rowa">
  29. <td>Day</td>
  30. <td>{{ _self.accrual(day.0) }}</td>
  31. {% for n in range(1, max) %}
  32. <td title="{{ day[n].total|number_format }}">{{ _self.delta(day, n) }}</td>
  33. {% endfor %}
  34. </tr>
  35. <tr class="rowb">
  36. <td>Week</td>
  37. <td>{{ _self.accrual(week.0) }}</td>
  38. {% for n in range(1, max) %}
  39. <td title="{{ week[n].total|number_format }}">{{ _self.delta(week, n) }}</td>
  40. {% endfor %}
  41. </tr>
  42. <tr class="rowb">
  43. <td>Month</td>
  44. <td>{{ _self.accrual(month.0) }}</td>
  45. {% for n in range(1, max) %}
  46. <td title="{{ month[n].total|number_format }}">{{ _self.delta(month, n) }}</td>
  47. {% endfor %}
  48. </tr>
  49. </table>
  50. </div>
  51. <div class="pad box">
  52. <h2>Item Purchases</h2>
  53. <table>
  54. <tr class="colhead">
  55. <td>Item</td>
  56. <td>Last day</td>
  57. <td>Last week</td>
  58. <td>Last month</td>
  59. <td>Last quarter</td>
  60. <td>Last year</td>
  61. <td>Total</td>
  62. </tr>
  63. {% set item = bonus.itemPurchase %}
  64. {% set day = bonus.expenditureRange('DAY', 0, 1) %}
  65. {% set week = bonus.expenditureRange('WEEK', 0, 1) %}
  66. {% set month = bonus.expenditureRange('MONTH', 0, 1) %}
  67. {% set quarter = bonus.expenditureRange('WEEK', 0, 13) %}
  68. {% set year = bonus.expenditureRange('YEAR', 0, 1) %}
  69. {% for i in item %}
  70. <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
  71. <td>{{ i.title }}</td>
  72. <td>{{ day[i.id].total|number_format }}</td>
  73. <td>{{ week[i.id].total|number_format }}</td>
  74. <td>{{ month[i.id].total|number_format }}</td>
  75. <td>{{ quarter[i.id].total|number_format }}</td>
  76. <td>{{ year[i.id].total|number_format }}</td>
  77. <td>{{ i.total|number_format }}</td>
  78. </tr>
  79. {% endfor %}
  80. </table>
  81. </div>
  82. <div class="pad box">
  83. <h2>Top 10 Users</h2>
  84. <table>
  85. <tr class="colhead">
  86. <td>&nbsp;</td>
  87. <td style="text-align: center;" colspan="2">Hoarders</td>
  88. <td style="text-align: center;" colspan="2">Spenders</td>
  89. <td style="text-align: center;" colspan="2">Pool Contributors</td>
  90. <td style="text-align: center;" colspan="2">Overall Spenders</td>
  91. <td>&nbsp;</td>
  92. </tr>
  93. <tr class="colhead">
  94. <td>&nbsp;</td>
  95. <td style="text-align: right;">Points</td>
  96. <td>User</td>
  97. <td style="text-align: right;">Points</td>
  98. <td>User</td>
  99. <td style="text-align: right;">Points</td>
  100. <td>User</td>
  101. <td style="text-align: right;">Points</td>
  102. <td>User</td>
  103. <td>&nbsp;</td>
  104. </tr>
  105. {% set limit = 10 %}
  106. {% set hoarders = bonus.topHoarders(limit) %}
  107. {% set spenders = bonus.topSpenders(limit) %}
  108. {% set poolers = bonus.topPoolContributors(limit) %}
  109. {% set overall = bonus.topAggregateSpenders(limit) %}
  110. {% for i in range(0, limit - 1) %}
  111. <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
  112. <td style="text-align: right">{{ i + 1 }}</td>
  113. <td style="text-align: right">{{ _self.total(hoarders, i) }}</td>
  114. <td>{{ _self.user(hoarders, i) }}</td>
  115. <td style="text-align: right">{{ _self.total(spenders, i) }}</td>
  116. <td>{{ _self.user(spenders, i) }}</td>
  117. <td style="text-align: right">{{ _self.total(poolers, i) }}</td>
  118. <td>{{ _self.user(poolers, i) }}</td>
  119. <td style="text-align: right">{{ _self.total(overall, i) }}</td>
  120. <td>{{ _self.user(overall, i) }}</td>
  121. <td style="text-align: right">{{ i + 1 }}</td>
  122. </tr>
  123. {% endfor %}
  124. </table>
  125. </div>