Skip to content

refactor: share sync policy across stores#679

Open
xXJSONDeruloXx wants to merge 1 commit intoutkarshdalal:masterfrom
xXJSONDeruloXx:refactor/service-sync-policy
Open

refactor: share sync policy across stores#679
xXJSONDeruloXx wants to merge 1 commit intoutkarshdalal:masterfrom
xXJSONDeruloXx:refactor/service-sync-policy

Conversation

@xXJSONDeruloXx
Copy link
Contributor

@xXJSONDeruloXx xXJSONDeruloXx commented Feb 28, 2026

Summary by cubic

Centralized sync decision logic into a shared ServiceSyncPolicy to remove duplication and keep Amazon, Epic, and GOG services consistent. This preserves behavior for initial/manual/auto sync and throttle while simplifying maintenance.

  • Refactors
    • Added ServiceSyncPolicy with shouldSyncOnColdStart, shouldSyncForAction, and remainingThrottleMinutes.
    • Updated AmazonService, EpicService, and GOGService to use the policy on start and when handling actions.
    • Replaced inline throttle checks with shared helpers and aligned logging for manual/auto/cold-start cases.
    • No functional changes intended; existing throttle and initial sync behavior is preserved.

Written for commit 6a548af. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Centralized synchronization throttling logic across all services for more consistent and predictable sync behavior.
    • Improved handling of manual and automatic sync timing to ensure reliable cold-start and restart operations.
    • Enhanced sync decision-making to better balance user-initiated syncs with automatic background synchronization.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa629bb and 6a548af.

📒 Files selected for processing (4)
  • app/src/main/java/app/gamenative/service/ServiceSyncPolicy.kt
  • app/src/main/java/app/gamenative/service/amazon/AmazonService.kt
  • app/src/main/java/app/gamenative/service/epic/EpicService.kt
  • app/src/main/java/app/gamenative/service/gog/GOGService.kt

📝 Walkthrough

Walkthrough

A new ServiceSyncPolicy singleton centralizes sync throttling and cold-start decision logic, replacing ad-hoc time calculations in three service implementations (Amazon, Epic, GOG). The policy provides methods to determine sync eligibility based on initial-sync state, throttle duration, and action type.

Changes

Cohort / File(s) Summary
ServiceSyncPolicy (New)
app/src/main/java/app/gamenative/service/ServiceSyncPolicy.kt
New singleton object with three public methods: shouldSyncOnColdStart (checks initial-sync state and throttle window), shouldSyncForAction (routes decisions based on action type), and remainingThrottleMinutes (computes remaining throttle time); all methods support testability via optional now parameter.
Service Sync Refactoring
app/src/main/java/app/gamenative/service/.../AmazonService.kt, app/src/main/java/app/gamenative/service/.../EpicService.kt, app/src/main/java/app/gamenative/service/.../GOGService.kt
Refactored startup and command handling to delegate throttling decisions to ServiceSyncPolicy, replacing direct time-based checks; adjusted logging to reflect policy-driven outcomes (manual vs. automatic vs. throttled sync); unified action branching in onStartCommand through shouldSyncForAction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A policy hops to the rescue, so keen,
Throttle and sync now have central routine!
Three services smile, their logic so clean,
From tangled old checks to decisions pristine. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: share sync policy across stores' directly and clearly describes the main change: creating a centralized ServiceSyncPolicy object and applying it across multiple service implementations (AmazonService, EpicService, GOGService).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant