-
Notifications
You must be signed in to change notification settings - Fork 0
Update sync for active proposals: votes and proposal updates #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |||||
| "context" | ||||||
| "encoding/json" | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "time" | ||||||
|
|
||||||
| "github.com/goverland-labs/snapshot-sdk-go/client" | ||||||
|
|
@@ -13,21 +14,25 @@ import ( | |||||
| "github.com/goverland-labs/goverland-datasource-snapshot/internal/db" | ||||||
| ) | ||||||
|
|
||||||
| const gap = 30 * time.Minute | ||||||
| const ( | ||||||
| gapMessages = 1 * time.Hour | ||||||
| gapProposalUpdate = 10 * time.Minute | ||||||
| ) | ||||||
|
|
||||||
| type ActiveProposalsWorker struct { | ||||||
| sdk *snapshot.SDK | ||||||
| proposals *db.ProposalService | ||||||
|
|
||||||
| checkInterval time.Duration | ||||||
| checkInterval time.Duration | ||||||
| unrpocessedSpaces unprocessedSpacesFinder | ||||||
| } | ||||||
|
|
||||||
| func NewActiveProposalsWorker(sdk *snapshot.SDK, proposals *db.ProposalService, checkInterval time.Duration) *ActiveProposalsWorker { | ||||||
| func NewActiveProposalsWorker(sdk *snapshot.SDK, proposals *db.ProposalService, unrpocessedSpaces unprocessedSpacesFinder, checkInterval time.Duration) *ActiveProposalsWorker { | ||||||
| return &ActiveProposalsWorker{ | ||||||
| sdk: sdk, | ||||||
| proposals: proposals, | ||||||
|
|
||||||
| checkInterval: checkInterval, | ||||||
| sdk: sdk, | ||||||
| proposals: proposals, | ||||||
| unrpocessedSpaces: unrpocessedSpaces, | ||||||
| checkInterval: checkInterval, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -51,35 +56,45 @@ func (w *ActiveProposalsWorker) Start(ctx context.Context) error { | |||||
| } | ||||||
|
|
||||||
| func (w *ActiveProposalsWorker) loop(ctx context.Context) error { | ||||||
| ids, err := w.proposals.GetProposalIDsForUpdate(nil, gap, proposalsPerRequest, false) | ||||||
| spaces, err := w.unrpocessedSpaces.FindSpacesWithProposalsUpdates(time.Now().Add(-gapMessages)) | ||||||
|
||||||
| spaces, err := w.unrpocessedSpaces.FindSpacesWithProposalsUpdates(time.Now().Add(-gapMessages)) | |
| spaces, err := w.unrpocessedSpaces.FindSpacesWithProposalsUpdates(time.Time{}) |
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message text is misleading and contains typos: this path is fetching spaces with proposal updates, but the message says "paces" and "new votes". Update the message so logs/errors accurately describe the failure source.
| return fmt.Errorf("get paces with new votes: %w", err) | |
| return fmt.Errorf("get spaces with proposal updates: %w", err) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ const ( | |||||
|
|
||||||
| type unprocessedSpacesFinder interface { | ||||||
| FindSpacesWithNewVotes(after time.Time) ([]string, error) | ||||||
| FindSpacesWithProposalsUpdates(after time.Time) ([]string, error) | ||||||
| } | ||||||
|
|
||||||
| type VoteWorker struct { | ||||||
|
|
@@ -156,7 +157,7 @@ func (w *VoteWorker) loopActive(ctx context.Context) error { | |||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| ids, err := w.proposals.GetProposalIDsForUpdate(spaces, gap, proposalsPerRequest, true) | ||||||
| ids, err := w.proposals.GetProposalIDsForUpdate(spaces, 0, proposalsPerRequest, true) | ||||||
|
||||||
| ids, err := w.proposals.GetProposalIDsForUpdate(spaces, 0, proposalsPerRequest, true) | |
| ids, err := w.proposals.GetProposalIDsForUpdate(spaces, votesCreatedAtGap, proposalsPerRequest, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field/parameter name
unrpocessedSpacesappears to be a misspelling (likelyunprocessedSpaces). Since this worker just introduced this dependency, consider correcting the identifier now to avoid propagating the typo across the codebase (and keep it consistent withunprocessedSpacesFinder).