Add HowLongToBeat estimates to game cards
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Fetch HLTB main/extra/completionist hours when a game item is saved
- Re-fetch only when name or category changes on edit
- Steam imports also fetch HLTB for each selected game
- Cards show compact HLTB row: "HLTB: 40h · +extra 60h · 100% 100h"
- Edit form shows HLTB breakdown as a hint next to Total hours field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-31 23:04:36 +03:00
parent a4c31bf40b
commit ffcd8c40b4
7 changed files with 100 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ from django.urls import reverse
from .models import Item
from .forms import ItemForm, SignupForm
from . import steam as steam_api
from . import hltb as hltb_api
def signup(request):
@@ -56,6 +57,7 @@ def item_add(request):
item = form.save(commit=False)
item.user = request.user
item.save()
hltb_api.apply_to_item(item)
return redirect('backlogger:list')
else:
form = ItemForm()
@@ -68,7 +70,9 @@ def item_edit(request, pk):
if request.method == 'POST':
form = ItemForm(request.POST, instance=item)
if form.is_valid():
form.save()
updated = form.save()
if 'name' in form.changed_data or 'category' in form.changed_data:
hltb_api.apply_to_item(updated)
return redirect('backlogger:list')
else:
form = ItemForm(instance=item)
@@ -139,13 +143,14 @@ def steam_import(request):
continue
hours = game['hours']
progress = min(100.0, hours) if hours > 0 else 0.0
Item.objects.create(
item = Item.objects.create(
user=request.user,
category=Item.GAMES,
name=game['name'],
hours_played=hours,
progress_percent=progress,
)
hltb_api.apply_to_item(item)
imported += 1
del request.session['steam_games']