fix(contribution): only publish adoptions with contributionDistributed=true

When publishing adoption events to mining-admin-service:
- Only include adoptions where contributionDistributed=true (already processed)
- Force status to 'MINING_ENABLED' since these are active adoptions

This ensures mining-admin-service only counts valid, processed adoptions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-13 01:49:09 -08:00
parent 20eabbb85f
commit 1f699fbfe1
1 changed files with 6 additions and 1 deletions

View File

@ -220,7 +220,11 @@ export class AdminController {
failedCount: number;
message: string;
}> {
// 只发布已分配算力的认种记录contributionDistributed = true
const adoptions = await this.prisma.syncedAdoption.findMany({
where: {
contributionDistributed: true,
},
select: {
originalAdoptionId: true,
accountSequence: true,
@ -241,12 +245,13 @@ export class AdminController {
try {
await this.unitOfWork.executeInTransaction(async () => {
const events = batch.map((adoption) => {
// 已分配算力的认种记录status 强制设置为 MINING_ENABLED
const event = new AdoptionSyncedEvent(
adoption.originalAdoptionId,
adoption.accountSequence,
adoption.treeCount,
adoption.adoptionDate,
adoption.status,
'MINING_ENABLED',
adoption.contributionPerTree.toString(),
);