Commit Graph

10 Commits

Author SHA1 Message Date
Matthieu B
6cb00478da Merge pull request #1203 from wizarrrr/fix/1121-watch-time-calculation
fix: use playback position instead of file duration for watch time
2026-03-29 16:25:47 +02:00
Matthieu B
73c29458fe fix: resolve all test failures, linting errors, and type errors
- Fix 55 test failures caused by missing request contexts and incorrect
  session_transaction() usage across 8 test files
- Fix ruff import sorting errors and unused imports
- Fix 122 type errors: rename method override parameters to match base
  classes, add None guards for fetchone()/datetime, widen dict type
  annotations, add type: ignore for SQLAlchemy stub limitations
- Add [tool.ty.rules] config to suppress unsupported-base warnings
- Fix _ variable shadowing gettext in wizard routes
- Add noqa: ARG002 for unused method arguments required by base class
2026-03-29 16:20:23 +02:00
Matthieu B
65ed356d62 fix: use playback position instead of file duration for watch time (#1121)
Jellyfin and Emby collectors were recording RunTimeTicks (total file
runtime) as the session duration, causing severe overestimation when
users stopped partway through long titles.

- JellyfinCollector._emit_session_event: on session_end, use position_ms
  (last known playback position) as duration_ms; fall back to
  raw_duration_ms only when position_ms is unavailable or zero.
- EmbyCollector._emit_session_event: identical fix (shared API shape).
- JellyfinHistoricalImporter._process_item: for partially-watched items
  (UserData.Played == false) use PlaybackPositionTicks; keep RunTimeTicks
  only for fully-played items where position has already been reset.
- historical_duration_source metadata field now accurately reflects
  which source was used (runtime_ticks, playback_position_ticks, or
  runtime_ticks_fallback).

Plex was already correct via elapsed-time tracking in SessionManager.
2026-03-29 16:15:56 +02:00
Matthieu B
ac36e793e1 refactor: improve code formatting and readability across multiple files 2025-12-09 14:12:17 +01:00
Douw Jacobs
f574120a90 fix: audiobookshelf history import order 2025-10-28 08:55:19 +02:00
Matthieu B
6a3632ec66 refactor: update type hints for better clarity and consistency across multiple files 2025-10-23 19:49:58 +02:00
Matthieu B
9b5aa0972a refactor: remove slop from media and new linting rules 2025-10-23 18:33:50 +02:00
Matthieu B
6ab5e024db Revert "Merge pull request #925 from wizarrrr/chore/python-3.14-upgrade"
This reverts commit 35dde7c19a, reversing
changes made to c8cf9905ba.
2025-10-19 14:05:59 +02:00
Matthieu B
294194eca7 Refactor code structure for improved readability and maintainability 2025-10-18 17:51:32 +02:00
Matthieu B
45053f041f Refactor historical data import service
- Moved utility functions for datetime parsing, tick conversion, and session building from `historical_data.py` to a new module `utils.py`.
- Deleted the `historical_data.py` file as its functionality is now encapsulated in the new utility module.
- Updated the `build_activity_session` function to utilize the new utility functions for improved readability and maintainability.
2025-10-18 15:37:48 +02:00