Compare commits

..

No commits in common. "4070b4e46e3bb8953cc6211e6dc6aebcd72fa629" and "feee9d6dace19270178dc9e8b39818203eee2e08" have entirely different histories.

8 changed files with 16 additions and 20 deletions

View File

@ -1,8 +1,7 @@
## 1.0.1 / 2023-01-30 22:17+01:00 ## Unrelease
* Add React
* Make it possible to edit sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/46) * Make it possible to edit sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/46)
* Show markers on smaller graphs to make it clearer which dates the session belong to
* Show only last 30 days on the homepage (https://git.kucharczyk.xyz/lukas/timetracker/issues/47)
## 1.0.0 / 2023-01-20 19:54+01:00 ## 1.0.0 / 2023-01-20 19:54+01:00

View File

@ -64,7 +64,7 @@ def get_chart(data, title="", xlabel="", ylabel=""):
plt.switch_backend("SVG") plt.switch_backend("SVG")
fig, ax = plt.subplots() fig, ax = plt.subplots()
fig.set_size_inches(10, 4) fig.set_size_inches(10, 4)
lines = ax.plot(x, y, "-o") ax.plot(x, y)
first = x[0] first = x[0]
last = x[-1] last = x[-1]
difference = last - first difference = last - first
@ -76,11 +76,7 @@ def get_chart(data, title="", xlabel="", ylabel=""):
elif difference.days < 720: elif difference.days < 720:
ax.xaxis.set_major_locator(mdates.MonthLocator()) ax.xaxis.set_major_locator(mdates.MonthLocator())
ax.xaxis.set_minor_locator(mdates.WeekdayLocator()) ax.xaxis.set_minor_locator(mdates.WeekdayLocator())
for line in lines:
line.set_marker("")
else: else:
for line in lines:
line.set_marker("")
ax.xaxis.set_major_locator(mdates.YearLocator()) ax.xaxis.set_major_locator(mdates.YearLocator())
ax.xaxis.set_minor_locator(mdates.MonthLocator()) ax.xaxis.set_minor_locator(mdates.MonthLocator())

View File

@ -17,7 +17,7 @@
<div class="dark:bg-gray-800 min-h-screen"> <div class="dark:bg-gray-800 min-h-screen">
<nav class="mb-4 bg-white dark:bg-gray-900 border-gray-200 rounded"> <nav class="mb-4 bg-white dark:bg-gray-900 border-gray-200 rounded">
<div class="container flex flex-wrap items-center justify-between mx-auto"> <div class="container flex flex-wrap items-center justify-between mx-auto">
<a href="{% url 'list_sessions_recent' %}" class="flex items-center"> <a href="{% url 'index' %}" class="flex items-center">
<span class="text-4xl"></span> <span class="text-4xl"></span>
<span class="self-center text-xl font-semibold whitespace-nowrap text-white">Timetracker</span> <span class="self-center text-xl font-semibold whitespace-nowrap text-white">Timetracker</span>
</a> </a>

View File

@ -1,6 +1,6 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}{{ title }}{% endblock title %} {% block title %}Sessions{% endblock title %}
{% block content %} {% block content %}
<div class="text-center text-xl mb-4 dark:text-slate-400"> <div class="text-center text-xl mb-4 dark:text-slate-400">

View File

@ -3,7 +3,7 @@ from django.urls import path
from games import views from games import views
urlpatterns = [ urlpatterns = [
path("", views.list_sessions, {"filter": "recent"}, name="list_sessions_recent"), path("", views.index, name="index"),
path("add-game/", views.add_game, name="add_game"), path("add-game/", views.add_game, name="add_game"),
path("add-platform/", views.add_platform, name="add_platform"), path("add-platform/", views.add_platform, name="add_platform"),
path("add-session/", views.add_session, name="add_session"), path("add-session/", views.add_session, name="add_session"),

View File

@ -1,4 +1,4 @@
from datetime import datetime, timedelta from datetime import datetime
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from common.plots import playtime_over_time_chart from common.plots import playtime_over_time_chart
@ -73,7 +73,6 @@ def delete_session(request, session_id=None):
def list_sessions(request, filter="", purchase_id="", platform_id="", game_id=""): def list_sessions(request, filter="", purchase_id="", platform_id="", game_id=""):
context = {} context = {}
context["title"] = "Sessions"
if filter == "purchase": if filter == "purchase":
dataset = Session.objects.filter(purchase=purchase_id) dataset = Session.objects.filter(purchase=purchase_id)
@ -84,11 +83,6 @@ def list_sessions(request, filter="", purchase_id="", platform_id="", game_id=""
elif filter == "game": elif filter == "game":
dataset = Session.objects.filter(purchase__game=game_id) dataset = Session.objects.filter(purchase__game=game_id)
context["game"] = Game.objects.get(id=game_id) context["game"] = Game.objects.get(id=game_id)
elif filter == "recent":
dataset = Session.objects.filter(
timestamp_start__gte=datetime.now() - timedelta(days=30)
)
context["title"] = "Last 30 days"
else: else:
# by default, sort from newest to oldest # by default, sort from newest to oldest
dataset = Session.objects.all().order_by("-timestamp_start") dataset = Session.objects.all().order_by("-timestamp_start")
@ -145,3 +139,10 @@ def add_platform(request):
context["form"] = form context["form"] = form
context["title"] = "Add New Platform" context["title"] = "Add New Platform"
return render(request, "add.html", context) return render(request, "add.html", context)
def index(request):
context = {}
context["total_duration"] = Session().duration_sum
context["title"] = "Index"
return render(request, "index.html", context)

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "timetracker" name = "timetracker"
version = "1.0.1" version = "1.0.0"
description = "A simple time tracker." description = "A simple time tracker."
authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"] authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"]
license = "GPL" license = "GPL"

View File

@ -19,7 +19,7 @@ from django.urls import include, path
from django.views.generic import RedirectView from django.views.generic import RedirectView
urlpatterns = [ urlpatterns = [
path("", RedirectView.as_view(url="/tracker")), path("", RedirectView.as_view(url="/tracker/list-sessions")),
path("tracker/", include("games.urls")), path("tracker/", include("games.urls")),
] ]