From 85ee10c1c56b9e2bebe1bde0a3b22a09208d88b6 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 21 May 2024 15:37:59 +0800 Subject: [PATCH 01/33] add tables for public inventory --- .../db/migrations/0177.do.public_item.sql | 71 +++++++++++++++++++ .../db/migrations/0177.undo.public_item.sql | 13 ++++ 2 files changed, 84 insertions(+) create mode 100755 packages/db/migrations/0177.do.public_item.sql create mode 100755 packages/db/migrations/0177.undo.public_item.sql diff --git a/packages/db/migrations/0177.do.public_item.sql b/packages/db/migrations/0177.do.public_item.sql new file mode 100755 index 000000000..3ff7bcb03 --- /dev/null +++ b/packages/db/migrations/0177.do.public_item.sql @@ -0,0 +1,71 @@ +-- Type: DO +-- Name: public_item +-- Description: Create a table for public items + +BEGIN; + +CREATE TABLE omnivore.public_item_source ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + name TEXT NOT NULL, + topics TEXT[] NOT NULL, + thumbnail TEXT NOT NULL, + url TEXT NOT NULL, + language_codes TEXT[] NOT NULL, + created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE omnivore.public_item ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + source_id uuid NOT NULL, -- user_id or public_item_source_id + type TEXT NOT NULL, -- public feeds, newsletters, or user recommended + title TEXT NOT NULL, + url TEXT NOT NULL, + thumbnail TEXT, + preview_content TEXT, + language_code TEXT, + author TEXT, + dir TEXT, + published_at timestamptz, + created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE omnivore.public_item_features ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE, + classified_topic TEXT, + sentiment_score FLOAT, + writing_style TEXT, + popularity_score FLOAT, + embedding VECTOR(768), + created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX public_item_feature_public_item_id_idx ON omnivore.public_item_features(public_item_id); + +CREATE TABLE omnivore.public_item_stats ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE, + save_count INT NOT NULL DEFAULT 0, + like_count INT NOT NULL DEFAULT 0, + broadcast_count INT NOT NULL DEFAULT 0, + created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX public_item_stats_public_item_id_idx ON omnivore.public_item_stats(public_item_id); + +CREATE TABLE omnivore.public_item_interactions ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + user_id uuid NOT NULL REFERENCES omnivore.user(id) ON DELETE CASCADE, + public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE, + action TEXT NOT NULL, -- save, like, broadcast, comment, see + action_data TEXT, -- for comment, the comment text + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX public_item_interaction_user_id_idx ON omnivore.public_item_interactions(user_id); +CREATE INDEX public_item_interaction_public_item_id_idx ON omnivore.public_item_interactions(public_item_id); + +COMMIT; diff --git a/packages/db/migrations/0177.undo.public_item.sql b/packages/db/migrations/0177.undo.public_item.sql new file mode 100755 index 000000000..31ab4da9f --- /dev/null +++ b/packages/db/migrations/0177.undo.public_item.sql @@ -0,0 +1,13 @@ +-- Type: UNDO +-- Name: public_item +-- Description: Create a table for public items + +BEGIN; + +DROP TABLE omnivore.public_item_interactions; +DROP TABLE omnivore.public_item_stats; +DROP TABLE omnivore.public_item_features; +DROP TABLE omnivore.public_item; +DROP TABLE omnivore.public_item_source; + +COMMIT; From 912fc566a96db18c9e1f198dcb521e1a45fc028a Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 23 May 2024 11:32:14 +0800 Subject: [PATCH 02/33] add approved column and seen_at --- packages/db/migrations/0177.do.public_item.sql | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/db/migrations/0177.do.public_item.sql b/packages/db/migrations/0177.do.public_item.sql index 3ff7bcb03..4d0a1a750 100755 --- a/packages/db/migrations/0177.do.public_item.sql +++ b/packages/db/migrations/0177.do.public_item.sql @@ -8,9 +8,10 @@ CREATE TABLE omnivore.public_item_source ( id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), name TEXT NOT NULL, topics TEXT[] NOT NULL, - thumbnail TEXT NOT NULL, + thumbnail TEXT, url TEXT NOT NULL, language_codes TEXT[] NOT NULL, + approved BOOLEAN NOT NULL DEFAULT FALSE, created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP ); @@ -21,6 +22,7 @@ CREATE TABLE omnivore.public_item ( type TEXT NOT NULL, -- public feeds, newsletters, or user recommended title TEXT NOT NULL, url TEXT NOT NULL, + approved BOOLEAN NOT NULL DEFAULT FALSE, thumbnail TEXT, preview_content TEXT, language_code TEXT, @@ -68,4 +70,15 @@ CREATE TABLE omnivore.public_item_interactions ( CREATE INDEX public_item_interaction_user_id_idx ON omnivore.public_item_interactions(user_id); CREATE INDEX public_item_interaction_public_item_id_idx ON omnivore.public_item_interactions(public_item_id); +CREATE TABLE omnivore.library_item_interactions ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + user_id uuid NOT NULL REFERENCES omnivore.user(id) ON DELETE CASCADE, + library_item_id uuid NOT NULL REFERENCES omnivore.library_item(id) ON DELETE CASCADE, + action TEXT NOT NULL, -- seen + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX library_item_interaction_user_id_idx ON omnivore.library_item_interactions(user_id); +CREATE INDEX library_item_interaction_library_item_id_idx ON omnivore.library_item_interactions(library_item_id); + COMMIT; From 43ebdc30a18a427f94a289c48c540f564e4addfe Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 23 May 2024 11:36:01 +0800 Subject: [PATCH 03/33] update just read api --- packages/api/src/generated/graphql.ts | 140 ++++++++++++++++++++++ packages/api/src/generated/schema.graphql | 54 +++++++++ packages/api/src/schema.ts | 55 +++++++++ 3 files changed, 249 insertions(+) diff --git a/packages/api/src/generated/graphql.ts b/packages/api/src/generated/graphql.ts index aa96fbe3b..2eaa03ac2 100644 --- a/packages/api/src/generated/graphql.ts +++ b/packages/api/src/generated/graphql.ts @@ -1363,6 +1363,64 @@ export type JoinGroupSuccess = { group: RecommendationGroup; }; +export type JustReadFeedError = { + __typename?: 'JustReadFeedError'; + errorCodes: Array; +}; + +export enum JustReadFeedErrorCode { + BadRequest = 'BAD_REQUEST', + Unauthorized = 'UNAUTHORIZED' +} + +export type JustReadFeedItem = { + __typename?: 'JustReadFeedItem'; + author?: Maybe; + broadcastCount?: Maybe; + comments?: Maybe>; + createdAt?: Maybe; + dir?: Maybe; + highlights?: Maybe; + id: Scalars['ID']; + languageCode?: Maybe; + likedCount?: Maybe; + previewContent?: Maybe; + publishedAt?: Maybe; + savedCount?: Maybe; + seen_at?: Maybe; + source?: Maybe; + thumbnail?: Maybe; + title: Scalars['String']; + topic: Scalars['String']; + type: Scalars['String']; + updatedAt?: Maybe; + url: Scalars['String']; +}; + +export type JustReadFeedResult = JustReadFeedError | JustReadFeedSuccess; + +export type JustReadFeedSource = { + __typename?: 'JustReadFeedSource'; + id: Scalars['ID']; + languageCodes?: Maybe>; + name: Scalars['String']; + thumbnail?: Maybe; + topics?: Maybe>; + url?: Maybe; +}; + +export type JustReadFeedSuccess = { + __typename?: 'JustReadFeedSuccess'; + topics: Array; +}; + +export type JustReadFeedTopic = { + __typename?: 'JustReadFeedTopic'; + items: Array; + name: Scalars['String']; + thumbnail?: Maybe; +}; + export type Label = { __typename?: 'Label'; color: Scalars['String']; @@ -2161,6 +2219,7 @@ export type Query = { hello?: Maybe; integration: IntegrationResult; integrations: IntegrationsResult; + justReadFeed: JustReadFeedResult; labels: LabelsResult; me?: Maybe; newsletterEmails: NewsletterEmailsResult; @@ -2212,6 +2271,12 @@ export type QueryIntegrationArgs = { }; +export type QueryJustReadFeedArgs = { + language?: InputMaybe; + location?: InputMaybe; +}; + + export type QueryRulesArgs = { enabled?: InputMaybe; }; @@ -4201,6 +4266,13 @@ export type ResolversTypes = { JoinGroupErrorCode: JoinGroupErrorCode; JoinGroupResult: ResolversTypes['JoinGroupError'] | ResolversTypes['JoinGroupSuccess']; JoinGroupSuccess: ResolverTypeWrapper; + JustReadFeedError: ResolverTypeWrapper; + JustReadFeedErrorCode: JustReadFeedErrorCode; + JustReadFeedItem: ResolverTypeWrapper; + JustReadFeedResult: ResolversTypes['JustReadFeedError'] | ResolversTypes['JustReadFeedSuccess']; + JustReadFeedSource: ResolverTypeWrapper; + JustReadFeedSuccess: ResolverTypeWrapper; + JustReadFeedTopic: ResolverTypeWrapper; Label: ResolverTypeWrapper