Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

Conversation

@kmendell
Copy link
Member

@kmendell kmendell commented Apr 4, 2025

Summary by Sourcery

Implement configurable sync schedule for registry synchronization with a new settings page and dynamic sync interval configuration

New Features:

  • Added a settings page to configure registry sync interval
  • Introduced dynamic sync interval configuration that can be changed at runtime

Enhancements:

  • Refactored sync service to support configurable sync intervals
  • Improved logging and error handling in sync mechanisms
  • Added app configuration service for managing application settings

Deployment:

  • Added database migrations to support new configuration table

Documentation:

  • Added settings page documentation and UI for managing sync configuration

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 4, 2025

Reviewer's Guide by Sourcery

This pull request introduces a configurable sync schedule for the registry synchronization process. It includes a new settings page, a flexible configuration system, and refactored sync service logic to dynamically check the sync interval. It also includes database migrations to support the new configuration options.

Sequence Diagram for Scheduled Sync Check

sequenceDiagram
  participant RegistrySyncService
  participant Database
  RegistrySyncService->>Database: getConfigValue('sync_interval')
  activate Database
  Database-->>RegistrySyncService: syncIntervalSetting
  deactivate Database
  RegistrySyncService->>RegistrySyncService: currentTime - lastSyncTime > syncIntervalMs
  alt needsSync == true
    RegistrySyncService->>RegistrySyncService: performSync()
    activate RegistrySyncService
    RegistrySyncService->>RegistrySyncService: getRegistryReposAxios()
    RegistrySyncService->>Database: incrementalSync()
    activate Database
    Database-->>RegistrySyncService: Success/Failure
    deactivate Database
    RegistrySyncService->>Database: Update sync statistics
    activate Database
    Database-->>RegistrySyncService: Success/Failure
    deactivate Database
    RegistrySyncService-->>RegistrySyncService: Complete
    deactivate RegistrySyncService
  else needsSync == false
    RegistrySyncService->>RegistrySyncService: Skip sync
  end
Loading

Entity Relationship Diagram for App Config Table

erDiagram
    app_config {
        string key PK
        string value
        integer updated_at
    }
Loading

Updated Class Diagram for RegistrySyncService

classDiagram
  class RegistrySyncService {
    - static instance: RegistrySyncService
    - logger: Logger
    - cronJob: cron.ScheduledTask
    - isSyncing: boolean
    - constructor()
    - scheduledSyncCheck(): Promise<void>
    - performSync(): Promise<void>
    + static getInstance(): RegistrySyncService
    + start(): void
    + stop(): void
    + syncNow(forceFullSync: boolean): void
  }
  note for RegistrySyncService "Sync interval is now configurable via database settings."
Loading

File-Level Changes

Change Details Files
Implements configurable registry synchronization schedule.
  • Introduces a new app_config table to store configuration settings.
  • Adds a settings page for configuring the registry sync interval.
  • Refactors the sync service to dynamically check the sync interval from the database.
  • Updates the settings table to accept string values to accommodate the sync interval.
  • Adds a form to the settings page to update the sync interval.
  • Adds a server action to update the sync interval in the database.
  • Adds a server action to reset all settings to default values.
  • Adds a toast message to confirm the sync interval has been updated.
  • Removes the syncIfNeeded method as its logic is now in scheduledSyncCheck.
src/lib/services/sync.ts
src/lib/components/ui/button/button.svelte
src/routes/+layout.server.ts
src/lib/services/database/migrations.ts
src/lib/components/ui/separator/separator.svelte
src/lib/components/header/header.svelte
src/lib/components/ui/button/index.ts
src/lib/components/ui/label/label.svelte
src/lib/components/ui/label/index.ts
src/lib/components/ui/separator/index.ts
package.json
src/routes/settings/+page.svelte
src/lib/services/database/app-config.ts
src/routes/settings/+page.server.ts
src/lib/components/ui/select/select-content.svelte
src/lib/components/ui/select/select-item.svelte
src/lib/components/ui/select/index.ts
src/lib/components/ui/form/index.ts
src/lib/components/ui/form/form-field-errors.svelte
src/lib/components/ui/form/form-element-field.svelte
src/lib/components/ui/form/form-field.svelte
src/lib/components/ui/select/select-trigger.svelte
src/lib/components/ui/form/form-fieldset.svelte
src/lib/components/ui/form/form-label.svelte
src/routes/api/settings/+server.ts
src/lib/components/ui/select/select-scroll-down-button.svelte
src/lib/components/ui/select/select-scroll-up-button.svelte
src/lib/components/ui/form/form-description.svelte
src/lib/components/ui/form/form-legend.svelte
src/routes/api/settings/reset/+server.ts
src/lib/components/ui/select/select-group-heading.svelte
src/lib/components/ui/select/select-separator.svelte
src/lib/components/ui/form/form-button.svelte

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kmendell kmendell marked this pull request as ready for review April 4, 2025 13:18
@kmendell kmendell requested a review from Copilot April 4, 2025 13:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 19 out of 35 changed files in this pull request and generated no comments.

Files not reviewed (16)
  • package.json: Language not supported
  • src/lib/components/header/header.svelte: Language not supported
  • src/lib/components/ui/button/button.svelte: Language not supported
  • src/lib/components/ui/form/form-button.svelte: Language not supported
  • src/lib/components/ui/form/form-description.svelte: Language not supported
  • src/lib/components/ui/form/form-element-field.svelte: Language not supported
  • src/lib/components/ui/form/form-field-errors.svelte: Language not supported
  • src/lib/components/ui/form/form-field.svelte: Language not supported
  • src/lib/components/ui/form/form-fieldset.svelte: Language not supported
  • src/lib/components/ui/form/form-label.svelte: Language not supported
  • src/lib/components/ui/form/form-legend.svelte: Language not supported
  • src/lib/components/ui/label/label.svelte: Language not supported
  • src/lib/components/ui/select/select-content.svelte: Language not supported
  • src/lib/components/ui/select/select-group-heading.svelte: Language not supported
  • src/lib/components/ui/select/select-item.svelte: Language not supported
  • src/lib/components/ui/select/select-scroll-down-button.svelte: Language not supported

Copy link
Contributor

@sourcery-ai sourcery-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.

Hey @kmendell - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a shared type definition for the configuration settings to ensure consistency between client and server.
  • The sync interval is checked every minute; consider making this configurable as well.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kmendell
Copy link
Member Author

kmendell commented Apr 4, 2025

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-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.

Hey @kmendell - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a constant for the cron schedule string to avoid duplication and improve maintainability.
  • The migrations file includes a migration to update the settings table to accept string values, but the code still uses INTEGER in some places; ensure consistency.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kmendell kmendell merged commit 2abd12a into main Apr 4, 2025
3 checks passed
@kmendell kmendell deleted the feat/settings branch April 4, 2025 22:51
kmendell added a commit that referenced this pull request Apr 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants