From 3e06cc73ec9836f35747f525ee2b4832e35641fc Mon Sep 17 00:00:00 2001 From: Yggdrasil Date: Wed, 14 Oct 2026 02:59:35 -0400 Subject: [PATCH 1/2] =?UTF-8?q?feat(reputation):=20nightly=20snapshot=20sw?= =?UTF-8?q?eep=20=E2=80=94=20they=20were=20never=20being=20created?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit computeAndSave only ran from the owner-only POST recompute, so GET /reputation/:userId returned nothing for anyone who never manually recomputed. A nightly @Cron recomputes for every contributor with a claimed bounty. Resolves #589 --- src/reputation/reputation.service.ts | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/reputation/reputation.service.ts b/src/reputation/reputation.service.ts index 0533cd2f..4b15e819 100644 --- a/src/reputation/reputation.service.ts +++ b/src/reputation/reputation.service.ts @@ -1,6 +1,7 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; +import { Cron, CronExpression } from '@nestjs/schedule'; import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; +import { IsNull, Not, Repository } from 'typeorm'; import { Bounty, Payment, ReputationSnapshot } from '../common/entities'; import { queryContributorCoreStats } from '../common/stats/contributor-stats.sql'; @@ -14,6 +15,8 @@ export interface ReputationHistoryOptions { @Injectable() export class ReputationService { + private readonly logger = new Logger(ReputationService.name); + constructor( @InjectRepository(Bounty) private readonly bountyRepo: Repository, @InjectRepository(Payment) @@ -47,6 +50,33 @@ export class ReputationService { return this.snapshotRepo.save(snapshot); } + /** + * Scheduled sweep — previously the ONLY way a snapshot was written was the + * owner-only POST /reputation/:userId/recompute, so GET returned nothing + * for anyone who never manually recomputed (#589). Nightly, recompute for + * every contributor who has a claimed bounty. + */ + @Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT) + async recomputeAllActiveContributors(): Promise { + const claimed = await this.bountyRepo.find({ + where: { claimedById: Not(IsNull()) }, + select: { claimedById: true }, + }); + const userIds = [...new Set(claimed.map((b) => b.claimedById!))]; + for (const userId of userIds) { + try { + await this.computeAndSave(userId); + } catch (err) { + this.logger.warn(`Reputation recompute failed for ${userId}: ${err}`); + } + } + if (userIds.length) { + this.logger.log( + `Recomputed reputation for ${userIds.length} contributor(s)`, + ); + } + } + async getLatest(userId: string): Promise { return this.snapshotRepo.findOne({ where: { userId }, From 722d275ee6f8b2c12bd8ca8e47c5947ea80617d4 Mon Sep 17 00:00:00 2001 From: yggdrasilworld Date: Sun, 18 Oct 2026 21:50:30 -0400 Subject: [PATCH 2/2] fix: repair merge glue that left the branch uncompilable The shared base carried half-written merge artifacts: an orphaned invokeOnLockedEscrow block in escrow.service.ts, duplicated returns plus a dead parsePagination in sponsors.controller.ts, and missing describe/it closers in github-webhooks.service.spec.ts. Aligned each with the intended form so the branch typechecks and its specs load. --- src/escrow/escrow.service.ts | 10 ++-------- src/github/github-webhooks.service.spec.ts | 3 +++ src/sponsors/sponsors.controller.ts | 21 --------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/escrow/escrow.service.ts b/src/escrow/escrow.service.ts index 6d2dd289..c252993f 100644 --- a/src/escrow/escrow.service.ts +++ b/src/escrow/escrow.service.ts @@ -584,20 +584,14 @@ export class EscrowService { recipients: Array<[string, number]>, manager?: EntityManager, ): Promise { - return this.invokeOnLockedEscrow(escrow, operation, () => - this.soroban.invoke( - 'release', - // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). - [u64(this.onChainKeyFor(escrow)), recipients], - this.contractOpts(escrow), - ), return this.invokeOnLockedEscrow( escrow, operation, () => this.soroban.invoke( 'release', - [this.onChainKeyFor(escrow), recipients], + // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). + [u64(this.onChainKeyFor(escrow)), recipients], this.contractOpts(escrow), ), manager, diff --git a/src/github/github-webhooks.service.spec.ts b/src/github/github-webhooks.service.spec.ts index 45bb6fe8..a35ac3be 100644 --- a/src/github/github-webhooks.service.spec.ts +++ b/src/github/github-webhooks.service.spec.ts @@ -869,6 +869,9 @@ describe('GithubWebhooksService', () => { expect(bountiesService.markInReview).not.toHaveBeenCalled(); expect(bountiesService.markMergedAndRelease).not.toHaveBeenCalled(); + }); + }); + // #308: a redelivered X-GitHub-Delivery used to hit the unique constraint // on webhook_events.deliveryId and escape handleEvent as a 500, so every // redelivery of that event failed forever. diff --git a/src/sponsors/sponsors.controller.ts b/src/sponsors/sponsors.controller.ts index b7a48cca..c097bf1e 100644 --- a/src/sponsors/sponsors.controller.ts +++ b/src/sponsors/sponsors.controller.ts @@ -26,25 +26,6 @@ function validatePage(limit?: number, offset?: number) { throw new BadRequestException('offset must be >= 0'); } return { limit, offset }; -/** - * Parse optional limit/offset query params, rejecting NaN, negatives, - * non-integers, and limits above MAX_PAGE_LIMIT with a 400 (#280). - */ -function parsePagination(limit?: string, offset?: string) { - const parse = (name: string, raw: string | undefined, min: number, max: number) => { - if (raw === undefined || raw === '') return undefined; - const n = Number(raw); - if (!Number.isInteger(n) || n < min || n > max) { - throw new BadRequestException( - `${name} must be an integer between ${min} and ${max}`, - ); - } - return n; - }; - return { - limit: parse('limit', limit, 1, MAX_PAGE_LIMIT), - offset: parse('offset', offset, 0, Number.MAX_SAFE_INTEGER), - }; } @ApiTags('sponsors') @@ -73,7 +54,6 @@ export class SponsorsController { ) { this.assertOwnsSponsor(user, id); return this.sponsorsService.dashboard(id, validatePage(limit, offset)); - return this.sponsorsService.dashboard(id, parsePagination(limit, offset)); } @ApiBearerAuth() @@ -91,6 +71,5 @@ export class SponsorsController { id, validatePage(limit, offset), ); - return this.sponsorsService.milestoneProgress(id, parsePagination(limit, offset)); } }