-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into app-reports
- Loading branch information
Showing
110 changed files
with
4,008 additions
and
1,272 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
5 changes: 5 additions & 0 deletions
5
hasura/migrations/default/1733533994467_compute_ratings/down.sql
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 @@ | ||
ALTER TABLE app | ||
DROP COLUMN IF EXISTS rating_sum; | ||
|
||
ALTER TABLE app | ||
DROP COLUMN IF EXISTS rating_count; |
26 changes: 26 additions & 0 deletions
26
hasura/migrations/default/1733533994467_compute_ratings/up.sql
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,26 @@ | ||
-- Step 1: Add new columns for the total rating sum and total number of ratings | ||
ALTER TABLE app | ||
ADD COLUMN IF NOT EXISTS rating_sum BIGINT DEFAULT 0; | ||
|
||
ALTER TABLE app | ||
ADD COLUMN IF NOT EXISTS rating_count BIGINT DEFAULT 0; | ||
|
||
-- Step 2: Update the new columns with the sum of ratings and count of ratings for each app | ||
UPDATE app | ||
SET | ||
rating_sum = ( | ||
SELECT | ||
COALESCE(SUM(rating), 0) | ||
FROM | ||
app_reviews | ||
WHERE | ||
app_reviews.app_id = app.id | ||
), | ||
rating_count = ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
app_reviews | ||
WHERE | ||
app_reviews.app_id = app.id | ||
); |
13 changes: 13 additions & 0 deletions
13
.../migrations/default/1733773864649_alter_table_public_app_alter_column_rating_sum/down.sql
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,13 @@ | ||
ALTER TABLE "public"."app" | ||
ALTER COLUMN "rating_count" TYPE bigint; | ||
|
||
ALTER TABLE "public"."app" | ||
ALTER COLUMN "rating_sum" TYPE bigint; | ||
|
||
alter table "public"."app" | ||
alter column "rating_sum" | ||
drop not null; | ||
|
||
alter table "public"."app" | ||
alter column "rating_count" | ||
drop not null; |
15 changes: 15 additions & 0 deletions
15
...ra/migrations/default/1733773864649_alter_table_public_app_alter_column_rating_sum/up.sql
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,15 @@ | ||
ALTER TABLE "public"."app" | ||
ALTER COLUMN "rating_sum" TYPE int4; | ||
|
||
ALTER TABLE "public"."app" | ||
ALTER COLUMN "rating_count" TYPE int4; | ||
|
||
alter table "public"."app" | ||
alter column "rating_sum" | ||
set | ||
not null; | ||
|
||
alter table "public"."app" | ||
alter column "rating_count" | ||
set | ||
not null; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.