forked from Giveth/impact-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from GeneralMagicio/feat/contribution-cap
Record user contribution
- Loading branch information
Showing
15 changed files
with
569 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddProjectUserRecord1727612450457 implements MigrationInterface { | ||
name = 'AddProjectUserRecord1727612450457'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "project_user_record" ("id" SERIAL NOT NULL, "totalDonationAmount" double precision NOT NULL DEFAULT '0', "eaTotalDonationAmount" double precision NOT NULL DEFAULT '0', "qfTotalDonationAmount" double precision NOT NULL DEFAULT '0', "projectId" integer NOT NULL, "userId" integer NOT NULL, CONSTRAINT "PK_491352d8cb0de1670d85f622f30" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`CREATE UNIQUE INDEX "IDX_29abdbcc3e6e7090cbc8fb1a90" ON "project_user_record" ("projectId", "userId") `, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "project_user_record" ADD CONSTRAINT "FK_6481d6181bd857725e903b0f330" FOREIGN KEY ("projectId") REFERENCES "project"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "project_user_record" ADD CONSTRAINT "FK_47c452701e3e8553fb01a904256" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "project_user_record" DROP CONSTRAINT "FK_47c452701e3e8553fb01a904256"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "project_user_record" DROP CONSTRAINT "FK_6481d6181bd857725e903b0f330"`, | ||
); | ||
await queryRunner.query( | ||
`DROP INDEX "public"."IDX_29abdbcc3e6e7090cbc8fb1a90"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "project_user_record"`); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Field, Float, ID, ObjectType } from 'type-graphql'; | ||
import { | ||
BaseEntity, | ||
Column, | ||
Entity, | ||
Index, | ||
ManyToOne, | ||
PrimaryGeneratedColumn, | ||
RelationId, | ||
} from 'typeorm'; | ||
import { Project } from './project'; | ||
import { ProjectRoundRecord } from './projectRoundRecord'; | ||
import { User } from './user'; | ||
|
||
@Entity() | ||
@ObjectType() | ||
@Index(['projectId', 'userId'], { | ||
unique: true, | ||
}) | ||
export class ProjectUserRecord extends BaseEntity { | ||
@Field(_type => ID) | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Field(_type => Float) | ||
@Column({ type: 'float', default: 0 }) | ||
totalDonationAmount: number; | ||
|
||
// Early access total donation amount | ||
@Field(_type => Float) | ||
@Column({ type: 'float', default: 0 }) | ||
eaTotalDonationAmount: number; | ||
|
||
// QF rounds total donation amount | ||
@Field(_type => Float) | ||
@Column({ type: 'float', default: 0 }) | ||
qfTotalDonationAmount: number; | ||
|
||
@Field(_type => Project) | ||
@ManyToOne(_type => Project, { eager: true }) | ||
project: Project; | ||
|
||
@Column({ nullable: false }) | ||
@RelationId((ps: ProjectRoundRecord) => ps.project) | ||
projectId: number; | ||
|
||
@Field(_type => User) | ||
@ManyToOne(_type => User, { eager: true }) | ||
user: User; | ||
|
||
@Column({ nullable: false }) | ||
@RelationId((ps: ProjectUserRecord) => ps.user) | ||
userId: number; | ||
} |
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
Oops, something went wrong.