Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Qacc round #145

Merged
merged 40 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7854350
add dynamic offset for time
ae2079 Nov 16, 2024
ebe7add
add dryRun flag
ae2079 Nov 16, 2024
925296e
put correct backend url for production
ae2079 Nov 16, 2024
e85a326
Merge pull request #141 from GeneralMagicio/runScriptWithDynamicTime
aminlatifi Nov 18, 2024
58b4499
Update main-pipeline.yml
geleeroyale Nov 19, 2024
6e98c99
Update staging-pipeline.yml
geleeroyale Nov 19, 2024
854a104
add variables for gitcoin score check
ae2079 Nov 24, 2024
f9404d4
add update user gitcoin score function
ae2079 Nov 24, 2024
86c8643
add validate donation based on kyc and score function
ae2079 Nov 24, 2024
04409f7
call validate donation based on kyc and score function in validate do…
ae2079 Nov 24, 2024
ed00f0d
add validate donation query to donation resolver
ae2079 Nov 24, 2024
a18e827
add test cases for validate donation resolver
ae2079 Nov 24, 2024
3d2839d
add score valid timestamp
ae2079 Nov 25, 2024
46996f6
update timestamp to bigint in the DB
ae2079 Nov 25, 2024
df4f1d7
change timestamp field type to string
ae2079 Nov 25, 2024
8e5f2aa
change timestamp field type to string
ae2079 Nov 25, 2024
3470966
Apply suggestions from code review
ae2079 Nov 25, 2024
1c38188
apply review changes
ae2079 Nov 26, 2024
9511bcc
use analysis score instead of gitcoin score
ae2079 Nov 26, 2024
b6e6cd7
add new endpoint to get caps
ae2079 Nov 26, 2024
80818e4
Resolve review changes
ae2079 Nov 26, 2024
6632272
Add tests for userCaps resolver
ae2079 Nov 26, 2024
31ad1c3
fix input of test
ae2079 Nov 26, 2024
3ebd200
change field name based on changes
ae2079 Nov 26, 2024
312d2ac
Remove redundant function
ae2079 Nov 26, 2024
0fa648d
Fix a bug in converting usd to pol
ae2079 Nov 26, 2024
73c0c68
Merge branch 'addGitCionScoreToDonationFlow' of github.com:GeneralMag…
ae2079 Nov 26, 2024
acbe033
Renamed variable
aminlatifi Nov 26, 2024
7f9628a
make variables dynamic
ae2079 Nov 26, 2024
04a4042
Merge branch 'addGitCionScoreToDonationFlow' of github.com:GeneralMag…
ae2079 Nov 26, 2024
14104b4
Merge pull request #142 from GeneralMagicio/addGitCionScoreToDonation…
ae2079 Nov 26, 2024
069635f
Renamed variable
aminlatifi Nov 26, 2024
4ace672
fix variable names
ae2079 Nov 26, 2024
240912a
Merge branch 'addTestsForKYCCaps' of github.com:GeneralMagicio/QAcc-B…
ae2079 Nov 26, 2024
d935172
fix tests
ae2079 Nov 27, 2024
024ca74
Merge pull request #143 from GeneralMagicio/addTestsForKYCCaps
aminlatifi Nov 27, 2024
0737e3f
add gitcoin passport scorer check to cap calculation flow
ae2079 Nov 28, 2024
311292d
add unit test for scorer score check
ae2079 Nov 28, 2024
b3c2c83
skip unused test
ae2079 Nov 28, 2024
4ec63f8
Merge pull request #144 from GeneralMagicio/addGitcoinScorerCheck
ae2079 Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ jobs:
cd QAcc-BE
## Update each backend service one by one
## First Deployment
docker compose down qacc-be-graph-ql1
docker compose down qacc-be-job
docker compose rm -fs qacc-be-graph-ql1
docker compose rm -fs qacc-be-job
docker compose up --force-recreate -d qacc-be-graph-ql1
docker compose up --force-recreate -d qacc-be-job

Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
script: |
cd QAcc-BE
## Second Deployment
docker compose down qacc-be-graph-ql2
docker compose rm -fs qacc-be-graph-ql2
docker compose up --force-recreate -d qacc-be-graph-ql2

# Wait for qacc-be-graph-ql2 to be healthy (timeout after 5 minutes)
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
script: |
cd QAcc-BE
## Third Deployment
docker compose down qacc-be-graph-ql3
docker compose rm -fs qacc-be-graph-ql3
docker compose up --force-recreate -d qacc-be-graph-ql3

# Wait for qacc-be-graph-ql3 to be healthy (timeout after 5 minutes)
Expand All @@ -263,4 +263,4 @@ jobs:
echo "qacc-be-graph-ql3 is not healthy, stopping deployment"
exit 1
fi
echo "First deployment phase completed successfully"
echo "First deployment phase completed successfully"
10 changes: 5 additions & 5 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ jobs:
cd QAcc-BE
## Update each backend service one by one
## First Deployment
docker compose down qacc-be-graph-ql1
docker compose down qacc-be-job
docker compose rm -fs qacc-be-graph-ql1
docker compose rm -fs qacc-be-job
docker compose up --force-recreate -d qacc-be-graph-ql1
docker compose up --force-recreate -d qacc-be-job

Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
script: |
cd QAcc-BE
## Second Deployment
docker compose down qacc-be-graph-ql2
docker compose rm -fs qacc-be-graph-ql2
docker compose up --force-recreate -d qacc-be-graph-ql2

# Wait for qacc-be-graph-ql2 to be healthy (timeout after 5 minutes)
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
script: |
cd QAcc-BE
## Third Deployment
docker compose down qacc-be-graph-ql3
docker compose rm -fs qacc-be-graph-ql3
docker compose up --force-recreate -d qacc-be-graph-ql3

# Wait for qacc-be-graph-ql3 to be healthy (timeout after 5 minutes)
Expand All @@ -263,4 +263,4 @@ jobs:
echo "qacc-be-graph-ql3 is not healthy, stopping deployment"
exit 1
fi
echo "First deployment phase completed successfully"
echo "First deployment phase completed successfully"
8 changes: 8 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,11 @@ ANKR_SYNC_CRONJOB_EXPRESSION=
# Reports database
MONGO_DB_URI=
MONGO_DB_REPORT_DB_NAME=

# Gitcoin score
GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE=
GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE=
# 1 day
GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS=86400000
MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD=
ACTIVATE_GITCOIN_SCORE_CHECK=
19 changes: 19 additions & 0 deletions migration/1732582914845-addScoreTimestampToUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddScoreTimestampToUser1732582914845
implements MigrationInterface
{
name = 'AddScoreTimestampToUser1732582914845';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user" ADD "passportScoreUpdateTimestamp" TIMESTAMP WITH TIME ZONE`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "passportScoreUpdateTimestamp"`,
);
}
}
13 changes: 13 additions & 0 deletions migration/1732584356154-addAnalysisScoreToUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddAnalysisScoreToUser1732584356154 implements MigrationInterface {
name = 'AddAnalysisScoreToUser1732584356154';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" ADD "analysisScore" real`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "analysisScore"`);
}
}
11 changes: 11 additions & 0 deletions src/constants/gitcoin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import config from '../config';

export const GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS =
(+config.get('GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS') as number) || 86400000; // 1 day
export const GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE =
(+config.get('GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE') as number) || 50;
export const GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE =
(+config.get('GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE') as number) || 15;
export const MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD =
(+config.get('MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD') as number) ||
1000;
28 changes: 28 additions & 0 deletions src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { ProjectVerificationForm } from './projectVerificationForm';
import { ReferredEvent } from './referredEvent';
import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics';
import { PrivadoAdapter } from '../adapters/privado/privadoAdapter';
import {
GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE,
GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE,
} from '../constants/gitcoin';

export const publicSelectionFields = [
'user.id',
Expand Down Expand Up @@ -117,6 +121,14 @@ export class User extends BaseEntity {
@Column({ type: 'real', nullable: true, default: null })
passportScore?: number;

@Field(_type => Float, { nullable: true })
@Column({ type: 'real', nullable: true, default: null })
analysisScore?: number;

@Field(_type => Date, { nullable: true })
@Column({ type: 'timestamptz', nullable: true })
passportScoreUpdateTimestamp?: Date;

@Field(_type => Number, { nullable: true })
@Column({ nullable: true, default: null })
passportStamps?: number;
Expand Down Expand Up @@ -228,6 +240,22 @@ export class User extends BaseEntity {
);
}

@Field(_type => Boolean, { nullable: true })
get hasEnoughGitcoinAnalysisScore(): boolean {
return !!(
this.analysisScore &&
this.analysisScore >= GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE
);
}

@Field(_type => Boolean, { nullable: true })
get hasEnoughGitcoinPassportScore(): boolean {
return !!(
this.passportScore &&
this.passportScore >= GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE
);
}

@Field(_type => Int, { nullable: true })
async donationsCount() {
return await Donation.createQueryBuilder('donation')
Expand Down
Loading