-
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.
- Loading branch information
Showing
138 changed files
with
47,319 additions
and
1,964 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"opRetro": { | ||
"projectId": "0xe434930e189c807b137ff0d8e2fa6a95eaa57dde574143a02ca0d7fb31a40bea" | ||
} | ||
} |
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 |
---|---|---|
@@ -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> {} | ||
} |
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,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> {} | ||
} |
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,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> {} | ||
} |
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,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> {} | ||
} |
Oops, something went wrong.