CollapseLauncher / Collapse

An Advanced Launcher for miHoYo/HoYoverse Games
MIT License
1.4k stars 64 forks source link

Implement Database Synchronization Function for Game Playtime #586

Closed bagusnl closed 1 month ago

bagusnl commented 1 month ago

Main Goal

Synchronize user game playtime to a database that the user can sync with other systems with privacy in mind.

Every user needs to have their own SQLite server (eg. Turso https://turso.tech/ free account should be sufficient) then supply all the necessary informations to Collapse (Database URL in https and the token). Collapse will generate the GUIDv7 as a user identifier table inside the database.

[!CAUTION] Changing User ID without taking notes of your current ID will cause the data to be dangling in the database and not being used anymore. While you can edit the database yourself, it's a bit tedious, so please do NOT lose your user ID.

Playtime synced to the database in a few mechanism:

  1. At first region load

    When region is loaded, playtime stats is first loaded from your local machine, then the system fetch and compare when the last time that region play time is updated, if the local is out of date then database value will be used and saved locally. If the database is out of date, then local value will be used and saved to the database.

  2. At game first launch (force push)

  3. Every 5 minutes when the game is running

  4. At game close (force push)

PR Status :

github-actions[bot] commented 1 month ago

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked ☁️ View the detailed Qodana report

Contact Qodana team Contact us at [qodana-support@jetbrains.com](mailto:qodana-support@jetbrains.com) - Or via our issue tracker: https://jb.gg/qodana-issue - Or share your feedback: https://jb.gg/qodana-discussions
bagusnl commented 1 month ago

@CollapseLauncher/core-maintainers please finish review in 12 hours if you can, planning to merge this PR on the weekend

bagusnl commented 1 month ago

After discussing with neon in chat, I'm merging this PR. Should there be any concern of the code, hit me up in this PR comment or directly to me