Skip to content

Commit af65da5

Browse files
committed
Omit platforms from delegation queries
1 parent f77b690 commit af65da5

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/flow/flow.controller.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -490,22 +490,19 @@ export class FlowController {
490490
const twitterUsername = twitterRes ? twitterRes.username : null;
491491

492492
const uniqueFarcasterCollectionDelegators = fid
493-
? await this.flowService.getCollectionDelegators(`${fid}`, 'FARCASTER')
493+
? await this.flowService.getCollectionDelegators(`${fid}`)
494494
: [];
495495

496496
const uniqueTwitterCollectionDelegators = twitterUsername
497-
? await this.flowService.getCollectionDelegators(
498-
twitterUsername,
499-
'TWITTER',
500-
)
497+
? await this.flowService.getCollectionDelegators(twitterUsername)
501498
: [];
502499

503500
const uniqueFarcasterBudgetDelegators = fid
504-
? await this.flowService.getBudgetDelegators(`${fid}`, 'FARCASTER')
501+
? await this.flowService.getBudgetDelegators(`${fid}`)
505502
: [];
506503

507504
const uniqueTwitterBudgetDelegators = twitterUsername
508-
? await this.flowService.getBudgetDelegators(twitterUsername, 'TWITTER')
505+
? await this.flowService.getBudgetDelegators(twitterUsername)
509506
: [];
510507

511508
// const fid = (res.metadata as FarcasterMetadata).fid;
@@ -529,8 +526,6 @@ export class FlowController {
529526
].map((el) => el.id),
530527
).size;
531528

532-
console.log('res2', res2);
533-
534529
const uniqueBudgetDelegatorsSize = new Set(
535530
[
536531
...uniqueFarcasterBudgetDelegators,
@@ -560,14 +555,12 @@ export class FlowController {
560555
? []
561556
: await this.flowService.getCollectionDelegators(
562557
`${fid}`,
563-
'FARCASTER',
564558
el.collectionId,
565559
)),
566560
...(!twitterUsername
567561
? []
568562
: await this.flowService.getCollectionDelegators(
569563
twitterUsername,
570-
'TWITTER',
571564
el.collectionId,
572565
)),
573566
],
@@ -580,15 +573,11 @@ export class FlowController {
580573
delegators: [
581574
...(!fid
582575
? []
583-
: await this.flowService.getBudgetDelegators(
584-
`${fid}`,
585-
'FARCASTER',
586-
)),
576+
: await this.flowService.getBudgetDelegators(`${fid}`)),
587577
...(!twitterUsername
588578
? []
589579
: await this.flowService.getBudgetDelegators(
590580
twitterUsername,
591-
'TWITTER',
592581
)),
593582
],
594583
};

src/flow/flow.service.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ export class FlowService {
541541
*/
542542
getCollectionDelegators = async (
543543
socialId: string,
544-
platform?: DelegationPlatform,
545544
collectionId?: number,
546545
): Promise<User[]> => {
547546
// Store users who have delegated to our target
@@ -553,8 +552,22 @@ export class FlowService {
553552
// Use BFS to traverse the delegation graph backward
554553
let currentBatch: string[] = [socialId];
555554

555+
// let iteration = 1;
556+
557+
// console.log('--------------------------------');
558+
556559
while (currentBatch.length > 0) {
557560
// Find all direct delegations to users in the current batch
561+
562+
// console.log(
563+
// 'iteration',
564+
// iteration++,
565+
// 'current batch',
566+
// currentBatch,
567+
// 'metadata',
568+
// { collectionId },
569+
// );
570+
558571
const directDelegations =
559572
await this.prismaService.collectionDelegation.findMany({
560573
where: {
@@ -563,7 +576,6 @@ export class FlowService {
563576
mode: 'insensitive',
564577
},
565578
collectionId,
566-
platform,
567579
},
568580
include: {
569581
user: true,
@@ -583,6 +595,8 @@ export class FlowService {
583595
// For each delegator, get their social ID to find who delegated to them
584596
}
585597
}
598+
599+
// console.log('Direct delegations', directDelegations);
586600
const delegatorSocialIds = await this.convertUserIdsToSocials(
587601
directDelegations.map((el) => el.userId),
588602
);
@@ -591,6 +605,8 @@ export class FlowService {
591605
currentBatch = nextBatch;
592606
}
593607

608+
// console.log('--------------------------------');
609+
594610
return delegators;
595611
};
596612

@@ -599,10 +615,7 @@ export class FlowService {
599615
* @param socialId The Twitter or Farcaster ID of the user receiving delegations
600616
* @returns Array of User objects who have delegated to the target
601617
*/
602-
getBudgetDelegators = async (
603-
socialId: string,
604-
platform?: DelegationPlatform,
605-
): Promise<User[]> => {
618+
getBudgetDelegators = async (socialId: string): Promise<User[]> => {
606619
// Store users who have delegated to our target
607620
const delegators: User[] = [];
608621

@@ -621,7 +634,6 @@ export class FlowService {
621634
in: currentBatch,
622635
mode: 'insensitive',
623636
},
624-
platform,
625637
},
626638
include: {
627639
user: true,

0 commit comments

Comments
 (0)