Compare commits
No commits in common. "8efce77062f9091e07aedc63a899f85a7ea58f3d" and "85f52fc73597a2b81cf8e232c2a3696404a9486a" have entirely different histories.
8efce77062
...
85f52fc735
|
@ -1,7 +1,4 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
* Improve the newcomer experience by guiding through each step
|
|
||||||
* Fix errors with empty database
|
|
||||||
* Fix negative playtimes being considered positive
|
|
||||||
* Add %d for days to common.util.time.format_duration
|
* Add %d for days to common.util.time.format_duration
|
||||||
* Set up tests, add tests for common.util.time
|
* Set up tests, add tests for common.util.time
|
||||||
* Display total hours played on homepage
|
* Display total hours played on homepage
|
||||||
|
|
16
Makefile
16
Makefile
|
@ -16,28 +16,28 @@ css-dev: css
|
||||||
npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --watch
|
npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --watch
|
||||||
|
|
||||||
makemigrations:
|
makemigrations:
|
||||||
poetry run python src/web/manage.py makemigrations
|
python src/web/manage.py makemigrations
|
||||||
|
|
||||||
migrate: makemigrations
|
migrate: makemigrations
|
||||||
poetry run python src/web/manage.py migrate
|
python src/web/manage.py migrate
|
||||||
|
|
||||||
dev: migrate
|
dev: migrate
|
||||||
TZ=Europe/Prague poetry run python src/web/manage.py runserver
|
python src/web/manage.py runserver
|
||||||
|
|
||||||
dumptracker:
|
dumptracker:
|
||||||
poetry run python src/web/manage.py dumpdata --format yaml tracker --output tracker_fixture.yaml
|
python src/web/manage.py dumpdata --format yaml tracker --output tracker_fixture.yaml
|
||||||
|
|
||||||
loadplatforms:
|
loadplatforms:
|
||||||
poetry run python src/web/manage.py loaddata platforms.yaml
|
python src/web/manage.py loaddata platforms.yaml
|
||||||
|
|
||||||
loadsample:
|
loadsample:
|
||||||
poetry run python src/web/manage.py loaddata sample.yaml
|
python src/web/manage.py loaddata sample.yaml
|
||||||
|
|
||||||
createsuperuser:
|
createsuperuser:
|
||||||
poetry run python src/web/manage.py createsuperuser
|
python src/web/manage.py createsuperuser
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
poetry run python src/web/manage.py shell
|
python src/web/manage.py shell
|
||||||
|
|
||||||
poetry.lock: pyproject.toml
|
poetry.lock: pyproject.toml
|
||||||
poetry install
|
poetry install
|
||||||
|
|
|
@ -23,9 +23,6 @@ def format_duration(
|
||||||
hour_seconds = 60 * minute_seconds
|
hour_seconds = 60 * minute_seconds
|
||||||
day_seconds = 24 * hour_seconds
|
day_seconds = 24 * hour_seconds
|
||||||
seconds_total = int(duration.total_seconds())
|
seconds_total = int(duration.total_seconds())
|
||||||
# timestamps where end is before start
|
|
||||||
if seconds_total < 0:
|
|
||||||
seconds_total = 0
|
|
||||||
days, remainder = divmod(seconds_total, day_seconds)
|
days, remainder = divmod(seconds_total, day_seconds)
|
||||||
hours, remainder = divmod(remainder, hour_seconds)
|
hours, remainder = divmod(remainder, hour_seconds)
|
||||||
minutes, seconds = divmod(remainder, minute_seconds)
|
minutes, seconds = divmod(remainder, minute_seconds)
|
||||||
|
|
|
@ -6,12 +6,8 @@
|
||||||
<div class="text-slate-300 mx-auto max-w-screen-lg text-center">
|
<div class="text-slate-300 mx-auto max-w-screen-lg text-center">
|
||||||
{% if session_count > 0 %}
|
{% if session_count > 0 %}
|
||||||
You have played a total of {{ session_count }} sessions for a total of {{ total_duration }}.
|
You have played a total of {{ session_count }} sessions for a total of {{ total_duration }}.
|
||||||
{% elif not game_available or not platform_available %}
|
|
||||||
There are no games in the database. Start by clicking "New Game" and "New Platform".
|
|
||||||
{% elif not purchase_available %}
|
|
||||||
There are no owned games. Click "New Purchase" at the top.
|
|
||||||
{% else %}
|
{% else %}
|
||||||
You haven't played any games yet. Click "New Session" to add one now.
|
Start by clicking the links at the top. To track playtime, you need to have at least 1 owned game.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
|
@ -104,12 +104,12 @@ def add_platform(request):
|
||||||
def index(request):
|
def index(request):
|
||||||
context = {}
|
context = {}
|
||||||
if Session.objects.count() == 0:
|
if Session.objects.count() == 0:
|
||||||
duration: str = ""
|
duration_value = 0
|
||||||
else:
|
else:
|
||||||
result = Session.objects.all().aggregate(Sum("duration_calculated"))
|
result = Session.objects.all().aggregate(Sum("duration_calculated"))
|
||||||
duration = format_duration(
|
context["total_duration"] = format_duration(
|
||||||
result["duration_calculated__sum"], "%H hours %m minutes"
|
result["duration_calculated__sum"], "%H hours %m minutes"
|
||||||
)
|
)
|
||||||
context["total_duration"] = duration
|
context["total_duration"] = duration_value
|
||||||
context["title"] = "Index"
|
context["title"] = "Index"
|
||||||
return render(request, "index.html", context)
|
return render(request, "index.html", context)
|
||||||
|
|
|
@ -51,8 +51,3 @@ class FormatDurationTest(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
result, "50 days, 10 hours, 34 minutes, 24 seconds, 4358064 total seconds"
|
result, "50 days, 10 hours, 34 minutes, 24 seconds, 4358064 total seconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_negative(self):
|
|
||||||
delta = timedelta(hours=-2)
|
|
||||||
result = format_duration(delta, "%H hours")
|
|
||||||
self.assertEqual(result, "0 hours")
|
|
||||||
|
|
Loading…
Reference in New Issue