Fix file view tracking: docs mark viewed, previews count one view (#786)

Opening a doc on its page never set FileGroup.viewed, so docs were missing
from Recently Viewed.  GET /api/docs/:id now marks the doc viewed, with the
same skip_viewed parameter as archives and videos.

The file preview marked a file viewed more than once: opening from a
?preview= URL sent two tracked requests, and every tag change re-fetched the
file with tracking on.  The fetches now skip tracking, and the preview marks
each opening viewed once.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-10-08 15:04:13 -06:00 • committed by GitHub
parent a1292005ce
commit 531721c157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 114 additions and 5 deletions

View file

@ -30,7 +30,8 @@ async def statistics(request: Request):
@openapi.response(HTTPStatus.NOT_FOUND, JSONErrorResponse)
async def get_doc(request: Request, file_group_id: int):
session = request.ctx.session
doc = _get_doc(session, file_group_id)
skip_viewed = request.args.get('skip_viewed', '').lower() == 'true'
doc = _get_doc(session, file_group_id, skip_viewed=skip_viewed)
return json_response(_doc_response(doc))