Compare commits

...

3 Commits

Author SHA1 Message Date
Lukáš Kucharczyk d211326c3f Make sure empty stats are 0
continuous-integration/drone/push Build is failing Details
2023-11-12 08:01:12 +01:00
Lukáš Kucharczyk 270a291f05 Change stats years to 2000 up to current year 2023-11-12 07:50:12 +01:00
Lukáš Kucharczyk 13b750ca92 Add stat for finished this year's games 2023-11-12 07:40:29 +01:00
3 changed files with 16 additions and 2 deletions

View File

@ -1,3 +1,8 @@
### Unreleased
## New
* Add stat for finished this year's games
## 1.4.0 / 2023-11-09 21:01+01:00
### New

View File

@ -45,6 +45,10 @@
<td class="px-2 sm:px-4 md:px-6 md:py-2">Finished</td>
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ all_finished_this_year.count }}</td>
</tr>
<tr>
<td class="px-2 sm:px-4 md:px-6 md:py-2">Finished ({{ year }})</td>
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ this_year_finished_this_year.count }}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -32,7 +32,12 @@ def model_counts(request):
def stats_dropdown_year_range(request):
return {"stats_dropdown_year_range": range(2018, 2024)}
result = {
"stats_dropdown_year_range": range(
datetime.now(ZoneInfo(settings.TIME_ZONE)).year, 1999, -1
)
}
return result
def add_session(request, purchase_id=None):
@ -331,7 +336,7 @@ def stats(request, year: int = 0):
this_year_spendings = this_year_purchases_without_refunded.aggregate(
total_spent=Sum(F("price"))
)
total_spent = this_year_spendings["total_spent"]
total_spent = this_year_spendings["total_spent"] or 0
games_with_playtime = (
Game.objects.filter(edition__purchase__session__in=this_year_sessions)