Skip to content

Commit

Permalink
Merge pull request #145 from GeneralMagicio/staging
Browse files Browse the repository at this point in the history
Release Qacc round
  • Loading branch information
ae2079 authored Nov 28, 2024
2 parents 513bd9e + 4ec63f8 commit 3982ff6
Show file tree
Hide file tree
Showing 16 changed files with 567 additions and 29 deletions.
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

0 comments on commit 3982ff6

Please sign in to comment.