Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/gittensory-miner/lib/portfolio-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function initPortfolioQueueStore(dbPath = resolvePortfolioQueueDbPath())
ON CONFLICT(repo_full_name, identifier) DO UPDATE SET
priority = excluded.priority,
status = 'queued'
WHERE miner_portfolio_queue.status <> 'in_progress'
`);
const getStatement = db.prepare(
"SELECT * FROM miner_portfolio_queue WHERE repo_full_name = ? AND identifier = ?",
Expand Down
11 changes: 11 additions & 0 deletions test/unit/miner-portfolio-queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ describe("gittensory-miner portfolio/queue store (#2292)", () => {
expect(store.dequeueNext()?.identifier).toBe("1"); // re-queued → dequeuable again
});

it("re-enqueue does not demote an in-progress item back to queued", () => {
const store = tempStore();
store.enqueue({ repoFullName: "o/a", identifier: "work", priority: 1 });
expect(store.dequeueNext()).toMatchObject({ identifier: "work", status: "in_progress", priority: 1 });
expect(store.enqueue({ repoFullName: "o/a", identifier: "work", priority: 99 })).toMatchObject({
identifier: "work",
status: "in_progress",
priority: 1,
});
});

it("re-enqueue keeps an item's FIFO position (no queue-jumping) even when timestamps collide", () => {
// Freeze the clock so A and B share an enqueued_at — the case where a restamp-vs-rowid inconsistency would show.
vi.useFakeTimers();
Expand Down
Loading