docs(contribution): add detailed comments for backfill task and findAccountsWithIncompleteUnlock

Explain the starvation root cause, unlock rules, pre-planting user scenario,
and future scalability considerations (cursor-based pagination).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-03 21:58:52 -08:00
parent 2565fa8259
commit 3f4b22b013
2 changed files with 28 additions and 5 deletions

View File

@ -283,8 +283,20 @@ export class ContributionScheduler implements OnModuleInit {
} }
/** /**
* 10 * 10
* / *
*
* 1. / LEVEL_OVERFLOW
*
* 2. synced_adoptions
* status = MINING_ENABLED
*
* ContributionCalculatorService
* - 1 5 3 10 5 15
* - hasAdopted 1 2 2 4 3
*
* LIMITstarvation
* Redis 9 10
*/ */
@Cron('*/10 * * * *') @Cron('*/10 * * * *')
async processContributionBackfill(): Promise<void> { async processContributionBackfill(): Promise<void> {

View File

@ -239,10 +239,21 @@ export class ContributionAccountRepository implements IContributionAccountReposi
* @param limit * @param limit
* @returns * @returns
*/ */
/**
* processContributionBackfill
*
* "不完整"
* - unlockedLevelDepth < 15155
* - unlockedBonusTiers < 34
*
*
* - LIMIT
* - 100 + updatedAt ASC
* 100 饿 / starvation
* - cursor-based pagination
* cron 100-500
*/
async findAccountsWithIncompleteUnlock(): Promise<ContributionAccountAggregate[]> { async findAccountsWithIncompleteUnlock(): Promise<ContributionAccountAggregate[]> {
// 查找已认种但未达到满解锁状态的账户:
// - unlockedLevelDepth < 15 或
// - unlockedBonusTiers < 3
const records = await this.client.contributionAccount.findMany({ const records = await this.client.contributionAccount.findMany({
where: { where: {
hasAdopted: true, hasAdopted: true,