add score feed

This commit is contained in:
Namekuji 2023-08-22 09:42:01 -04:00
parent 3f43f3d801
commit c11a1bc110
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532
2 changed files with 12 additions and 0 deletions

View file

@ -5,6 +5,7 @@ DROP INDEX IF EXISTS reaction_by_id;
DROP TABLE IF EXISTS reaction;
DROP INDEX IF EXISTS home_by_id;
DROP TABLE IF EXISTS home_timeline;
DROP MATERIALIZED VIEW IF EXISTS score_feed;
DROP MATERIALIZED VIEW IF EXISTS local_timeline;
DROP MATERIALIZED VIEW IF EXISTS global_timeline;
DROP MATERIALIZED VIEW IF EXISTS note_by_channel_id;

View file

@ -157,6 +157,17 @@ CREATE MATERIALIZED VIEW local_timeline AS
PRIMARY KEY ("createdAtDate", "createdAt", "userId", "userHost", "visibility")
WITH CLUSTERING ORDER BY ("createdAt" DESC);
CREATE MATERIALIZED VIEW score_feed AS
SELECT * FROM note
WHERE "createdAtDate" IS NOT NULL
AND "createdAt" IS NOT NULL
AND "userId" IS NOT NULL
AND "userHost" IS NOT NULL
AND "score" IS NOT NULL
AND "visibility" = 'public'
PRIMARY KEY ("createdAtDate", "score", "createdAt", "userId", "userHost", "visibility")
WITH CLUSTERING ORDER BY ("score" DESC, "createdAt" DESC);
CREATE TABLE home_timeline (
"feedUserId" ascii, -- For partitioning
"createdAtDate" date, -- For partitioning