-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify get donors and who liked projects query to exclude something
- Loading branch information
1 parent
a96c845
commit d89bdf4
Showing
6 changed files
with
112 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import { Reaction } from '../entities/reaction'; | ||
import { User } from '../entities/user'; | ||
|
||
export const findUsersWhoLikedProject = async ( | ||
export const findUsersWhoLikedProjectExcludeProjectOwner = async ( | ||
projectId: number, | ||
): Promise<{ walletAddress: string; email?: string }[]> => { | ||
return Reaction.createQueryBuilder('reaction') | ||
.leftJoin(User, 'user', 'reaction.userId = user.id') | ||
.select('LOWER(user.walletAddress) AS "walletAddress", user.email as email') | ||
.leftJoinAndSelect('reaction.project', 'project') | ||
.leftJoinAndSelect( | ||
User, | ||
'projectOwner', | ||
'project.adminUserId = projectOwner.id', | ||
) | ||
.select( | ||
'LOWER(user.walletAddress) AS "walletAddress", user.email as email, projectOwner.id as ownerId', | ||
) | ||
.where(`"projectId"=:projectId`, { | ||
projectId, | ||
}) | ||
.andWhere(`user.id != projectOwner.id`) | ||
.getRawMany(); | ||
}; |