Skip to content

Commit

Permalink
pull staging and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Jul 17, 2024
2 parents afcce53 + f14a053 commit 71ce0d1
Show file tree
Hide file tree
Showing 138 changed files with 47,319 additions and 1,964 deletions.
Binary file modified .DS_Store
Binary file not shown.
25 changes: 25 additions & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,33 @@ on:
- staging

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 20.11.0

# ESLint and Prettier must be in `package.json`
- name: Install Node.js dependencies
run: npm ci

- name: Run linters
uses: wearerequired/lint-action@v2
with:
eslint: true
#prettier: true
continue_on_error: true

test:
runs-on: ubuntu-latest
needs: run-linters
services:
# Label used to access the service container
redis:
Expand Down
11 changes: 2 additions & 9 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,11 @@ QF_ROUND_GOOGLE_SPREADSHEETS_PRIVATE_KEY=
QF_ROUND_GOOGLE_SPREADSHEETS_CLIENT_EMAIL=
QF_ROUND_DONATIONS_GOOGLE_SPREADSHEET_ID=

POIGN_ART_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/dan13ram/poignart-rinkeby
POIGN_ART_SERVICE_ACTIVE=true
POIGN_ART_RECIPIENT_ADDRESS=0x10E1439455BD2624878b243819E31CfEE9eb721C
POIGN_ART_ORIGIN_ADDRESS=
SYNC_POIGN_ART_CRONJOB_EXPRESSION=0 1 * * * *

CHANGE_API_KEYS=
CHANGE_API_NON_PROFITS_SEARCH_URL=


FRONTEND_URL=test.giveth.io
DAPP_MAILER_URL=
DAPP_MAILER_AUTHORIZATION_KEY=
ENABLE_DAPP_MAILER=false

GIVETH_IO_DAPP_BASE_URL=https://staging.giveth.io
GIVETH_IO_BACKEND_BASE_URL=http://localhost:3040
Expand Down Expand Up @@ -330,3 +321,5 @@ ZKEVM_MAINNET_NODE_HTTP_URL=

# ZKEVM CARDONA we should fill it as Infura doesnt support polygon zkevm
ZKEVM_CARDONA_NODE_HTTP_URL=

ENDAOMENT_ADMIN_WALLET_ADDRESS=0xfE3524e04E4e564F9935D34bB5e80c5CaB07F5b4
15 changes: 7 additions & 8 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ GIVETH_GIV_PRICES_URL=https://givback.develop.giveth.io/givPrice
PINATA_GATEWAY_ADDRESS=https://giveth.mypinata.cloud


POIGN_ART_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/dan13ram/poignart-rinkeby
POIGN_ART_SERVICE_ACTIVE=false
POIGN_ART_RECIPIENT_ADDRESS=0x66f59a4181f43b96fe929b711476be15c96b83b3
POIGN_ART_ORIGIN_ADDRESS=0x7a1dc1805f079a07ffd03845d3ec5b51ec8f9373
SYNC_POIGN_ART_CRONJOB_EXPRESSION=0 0 0 * * *

TRACE_FILE_UPLOADER_PASSWORD=hello_trace


Expand All @@ -103,9 +99,6 @@ PRIVATE_ETHERS_SECONDARY_TEST_KEY=0x2f8ca279705d6dfc44fb4507d02f6ef8bd0a50188695
PUBLIC_ETHERS_SECONDARY_TEST_KEY=0x05fCFaDDFEc046F393B97C8273ad0537e83EFC74

FRONTEND_URL=test.giveth.io
DAPP_MAILER_URL=
DAPP_MAILER_AUTHORIZATION_KEY=
ENABLE_DAPP_MAILER=false

GIVETH_IO_DAPP_BASE_URL=https://staging.giveth.io
GIVETH_IO_BACKEND_BASE_URL=http://localhost:3040
Expand Down Expand Up @@ -188,6 +181,10 @@ NUMBER_OF_BALANCE_AGGREGATOR_BATCH=7
QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION=1
# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
PROJECT_CAMPAIGNS_CACHE_DURATION=1
# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
QF_ROUND_AND_MAIN_CATEGORIES_CACHE_DURATION=1
# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
REFRESH_ESTIMATED_MATCHING_CACHE_DURATION=1


# OPTIONAL - default: *0 */5 * * * ( Every 5 minutes)
Expand Down Expand Up @@ -254,3 +251,5 @@ ZKEVM_MAINNET_NODE_HTTP_URL=https://polygon-zkevm.drpc.org

# ZKEVM CARDONA we should fill it as Infura doesnt support polygon zkevm, I found this rpc link from https://chainlist.org/chain/2442
ZKEVM_CARDONA_NODE_HTTP_URL=https://rpc.cardona.zkevm-rpc.com

ENDAOMENT_ADMIN_WALLET_ADDRESS=0xfE3524e04E4e564F9935D34bB5e80c5CaB07F5b4
5 changes: 5 additions & 0 deletions funding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"opRetro": {
"projectId": "0xe434930e189c807b137ff0d8e2fa6a95eaa57dde574143a02ca0d7fb31a40bea"
}
}
3 changes: 1 addition & 2 deletions migration/1646305490859-seedOrganizations.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { ORGANIZATION_LABELS } from '../src/entities/organization';

const { GIVETH, GIVING_BLOCK, TRACE, CHANGE } = ORGANIZATION_LABELS;
const { GIVETH, TRACE, CHANGE } = ORGANIZATION_LABELS;

export class seedOrganizations1646305490859 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`INSERT INTO organization (label,name,website) VALUES
('${GIVETH}','Giveth','https://giveth.io'),
('${TRACE}','Trace','https://trace.giveth.io'),
('${GIVING_BLOCK}','Giving Block','https://thegivingblock.com'),
('${CHANGE}','CHANGE','https://getchange.io')
;`);
}
Expand Down
4 changes: 2 additions & 2 deletions migration/1684654545845-add_some_mainnet_donations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '../src/services/userService';
import { findProjectById } from '../src/repositories/projectRepository';
import { Project } from '../src/entities/project';
import { updateTotalDonationsOfProject } from '../src/services/donationService';
import { calculateGivbackFactor } from '../src/services/givbackService';
import { AppDataSource } from '../src/orm';
import { updateProjectStatistics } from '../src/services/projectService';

const fromWalletAddress = '0x6bed0ce7be8dc307b69cfdc100f87db51bc3823a';
const txHash =
Expand Down Expand Up @@ -257,7 +257,7 @@ export class addSomeMainnetDonations1684654545845
`);
await updateUserTotalDonated(user.id);
await updateUserTotalReceived(project.adminUser?.id);
await updateTotalDonationsOfProject(tx.projectId as number);
await updateProjectStatistics(tx.projectId as number);
}
}

Expand Down
4 changes: 2 additions & 2 deletions migration/1696918830123-add_octant_donations_to_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
updateUserTotalDonated,
updateUserTotalReceived,
} from '../src/services/userService';
import { updateTotalDonationsOfProject } from '../src/services/donationService';
import { Donation } from '../src/entities/donation';
import { NETWORK_IDS } from '../src/provider';
import { updateProjectStatistics } from '../src/services/projectService';

const octantDonationTxHash =
'0xe70a8ee39511d3c186ea53c4bdd9fcd34f658d68ca7e1bbbc2b231630ac7fa3b';
Expand Down Expand Up @@ -108,7 +108,7 @@ export class addOctantDonationsToDb1696918830123 implements MigrationInterface {
`);
await updateUserTotalDonated(user.id);
await updateUserTotalReceived(project.adminUser?.id);
await updateTotalDonationsOfProject(tx.projectId as number);
await updateProjectStatistics(tx.projectId as number);
}
}

Expand Down
10 changes: 3 additions & 7 deletions migration/1703398409668-add_missed_op_donations_to_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ import {
updateUserTotalDonated,
updateUserTotalReceived,
} from '../src/services/userService';
import { updateTotalDonationsOfProject } from '../src/services/donationService';
import { Donation } from '../src/entities/donation';
import { NETWORK_IDS } from '../src/provider';
import {
refreshProjectDonationSummaryView,
refreshProjectEstimatedMatchingView,
} from '../src/services/projectViewsService';
import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService';
import { updateProjectStatistics } from '../src/services/projectService';

const QF_ROUND_ID = 5;
const millisecondTimestampToDate = (timestamp: number): Date => {
Expand Down Expand Up @@ -274,11 +271,10 @@ export class addMissedOpDonationsToDb1703398409668

await updateUserTotalDonated(user.id);
await updateUserTotalReceived(project.adminUser?.id);
await updateTotalDonationsOfProject(tx.projectId as number);
await updateProjectStatistics(tx.projectId as number);
}

await refreshProjectEstimatedMatchingView();
await refreshProjectDonationSummaryView();
}

async down(_queryRunner: QueryRunner): Promise<void> {
Expand Down
8 changes: 1 addition & 7 deletions migration/1716549958362-add_donations_mannually_to_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import {
updateUserTotalDonated,
updateUserTotalReceived,
} from '../src/services/userService';
import { updateTotalDonationsOfProject } from '../src/services/donationService';
import {
refreshProjectDonationSummaryView,
refreshProjectEstimatedMatchingView,
} from '../src/services/projectViewsService';
import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService';
import { updateProjectStatistics } from '../src/services/projectService';

const millisecondTimestampToDate = (timestamp: number): Date => {
Expand Down Expand Up @@ -395,12 +391,10 @@ export class AddDonationsMannuallyToDb1716549958362

await updateUserTotalDonated(user.id);
await updateUserTotalReceived(project.adminUser?.id);
await updateTotalDonationsOfProject(tx.projectId as number);
await updateProjectStatistics(tx.projectId as number);
}

await refreshProjectEstimatedMatchingView();
await refreshProjectDonationSummaryView();
}

async down(_queryRunner: QueryRunner): Promise<void> {
Expand Down
14 changes: 14 additions & 0 deletions migration/1717502321980-dropDonationSummaryView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class DropDonationSummaryView1717502321980
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
DROP MATERIALIZED VIEW IF EXISTS project_donation_summary_view;`,
);
}

public async down(_queryRunner: QueryRunner): Promise<void> {}
}
63 changes: 63 additions & 0 deletions migration/1717643016553-ProjectFuturePowerView_V2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ProjectFuturePowerViewV21717643016553
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
DROP
MATERIALIZED VIEW IF EXISTS public.project_future_power_view;
CREATE MATERIALIZED VIEW IF NOT EXISTS public.project_future_power_view AS
SELECT
innerview."projectId",
innerview."totalPower",
rank() OVER (
ORDER BY
innerview."totalPower" DESC
) AS "powerRank",
"powerRound".round + 1 as "round"
FROM
(
SELECT
project.id AS "projectId",
CASE project.verified and project."statusId" = 5 WHEN false THEN 0 :: double precision ELSE COALESCE(
sum(pp."boostedPower"),
0 :: double precision
) END AS "totalPower"
FROM
project project
JOIN (
SELECT
"powerRound".round,
"powerBoostingSnapshot"."projectId",
"powerBoostingSnapshot"."userId",
avg(
"powerBalanceSnapshot".balance * "powerBoostingSnapshot".percentage :: double precision / 100 :: double precision
) AS "boostedPower",
now() AS "updateTime"
FROM
power_round "powerRound"
JOIN power_snapshot "powerSnapshot" ON "powerSnapshot"."roundNumber" = "powerRound".round + 1 and "powerSnapshot".synced = true
JOIN power_balance_snapshot "powerBalanceSnapshot" ON "powerBalanceSnapshot"."powerSnapshotId" = "powerSnapshot".id
JOIN power_boosting_snapshot "powerBoostingSnapshot" ON "powerBoostingSnapshot"."powerSnapshotId" = "powerSnapshot".id
AND "powerBoostingSnapshot"."userId" = "powerBalanceSnapshot"."userId"
GROUP BY
"powerRound".round,
"powerBoostingSnapshot"."projectId",
"powerBoostingSnapshot"."userId"
) pp ON pp."projectId" = project.id
GROUP BY
project.id
) innerview,
power_round "powerRound"
ORDER BY
innerview."totalPower" DESC WITH DATA;
CREATE UNIQUE INDEX project_future_power_view_project_id_unique ON public.project_future_power_view ("projectId");
CREATE INDEX project_future_power_view_project_id ON public.project_future_power_view USING hash ("projectId") TABLESPACE pg_default;
`,
);
}

public async down(_queryRunner: QueryRunner): Promise<void> {}
}
62 changes: 62 additions & 0 deletions migration/1717643739652-ProjectPowerView_V2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ProjectPowerViewV21717643739652 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
DROP
MATERIALIZED VIEW IF EXISTS public.project_power_view;
CREATE MATERIALIZED VIEW IF NOT EXISTS public.project_power_view AS
SELECT
innerview."projectId",
ROUND(CAST(innerview."totalPower" as NUMERIC), 2) as "totalPower",
rank() OVER (
ORDER BY
innerview."totalPower" DESC
) AS "powerRank",
"powerRound".round
FROM
(
SELECT
project.id AS "projectId",
CASE project.verified and project."statusId" = 5 WHEN false THEN 0 :: double precision ELSE COALESCE(
sum(pp."boostedPower"),
0 :: double precision
) END AS "totalPower"
FROM
project project
LEFT JOIN (
SELECT
"powerRound".round,
"powerBoostingSnapshot"."projectId",
"powerBoostingSnapshot"."userId",
avg(
"powerBalanceSnapshot".balance * "powerBoostingSnapshot".percentage :: double precision / 100 :: double precision
) AS "boostedPower",
now() AS "updateTime"
FROM
power_round "powerRound"
JOIN power_snapshot "powerSnapshot" ON "powerSnapshot"."roundNumber" = "powerRound".round
JOIN power_balance_snapshot "powerBalanceSnapshot" ON "powerBalanceSnapshot"."powerSnapshotId" = "powerSnapshot".id
JOIN power_boosting_snapshot "powerBoostingSnapshot" ON "powerBoostingSnapshot"."powerSnapshotId" = "powerSnapshot".id
AND "powerBoostingSnapshot"."userId" = "powerBalanceSnapshot"."userId"
GROUP BY
"powerRound".round,
"powerBoostingSnapshot"."projectId",
"powerBoostingSnapshot"."userId"
) pp ON pp."projectId" = project.id
GROUP BY
project.id
) innerview,
power_round "powerRound"
ORDER BY
innerview."totalPower" DESC WITH DATA;
CREATE UNIQUE INDEX project_power_view_project_id_round_unique ON public.project_power_view ("projectId", "round");
CREATE INDEX project_power_view_project_id ON public.project_power_view USING hash ("projectId") TABLESPACE pg_default;
CREATE INDEX project_power_view_total_power ON public.project_power_view USING btree ("totalPower" DESC) TABLESPACE pg_default;
`,
);
}

public async down(_queryRunner: QueryRunner): Promise<void> {}
}
37 changes: 37 additions & 0 deletions migration/1717644442966-ProjectUserInstantPowerView_V2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ProjectUserInstantPowerViewV21717644442966
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP MATERIALIZED VIEW IF EXISTS PUBLIC.PROJECT_USER_INSTANT_POWER_VIEW;
CREATE MATERIALIZED VIEW IF NOT EXISTS PUBLIC.PROJECT_USER_INSTANT_POWER_VIEW AS
SELECT "powerBoosting"."id",
"powerBoosting"."projectId",
"powerBoosting"."userId",
("instantPowerBalance".BALANCE * "powerBoosting".PERCENTAGE :: double precision / 100 :: double precision) AS "boostedPower",
NOW() AS "updateTime"
FROM INSTANT_POWER_BALANCE "instantPowerBalance"
JOIN POWER_BOOSTING "powerBoosting" ON "powerBoosting"."userId" = "instantPowerBalance"."userId";
`);

await queryRunner.query(`
CREATE UNIQUE INDEX project_user_instant_power_view_id ON public.project_user_instant_power_view ("id");
`);

await queryRunner.query(`
CREATE UNIQUE INDEX project_user_instant_power_view_project_user_id ON public.project_user_instant_power_view ("projectId", "userId");
`);

await queryRunner.query(`
CREATE INDEX project_user_instant_power_view_project_id ON PUBLIC.PROJECT_USER_INSTANT_POWER_VIEW USING hash ("projectId") TABLESPACE pg_default;
`);
await queryRunner.query(`
CREATE INDEX PROJECT_USER_INSTANT_POWER_VIEW_TOTAL_POWER ON PUBLIC.PROJECT_USER_INSTANT_POWER_VIEW USING BTREE ("boostedPower" DESC) TABLESPACE PG_DEFAULT;
`);
}

public async down(_queryRunner: QueryRunner): Promise<void> {}
}
Loading

0 comments on commit 71ce0d1

Please sign in to comment.