Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions postgresql/schemas/db-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.create_article(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[])
CREATE OR REPLACE FUNCTION real_medium.create_article_v1(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[])
RETURNS text
AS $$
DECLARE
Expand Down Expand Up @@ -192,6 +192,15 @@ END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.create_article(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[])
RETURNS text
AS $$
BEGIN
RETURN real_medium.create_article_v1(_title, _slug, _body, _description, _user_id, _tags);
END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.is_favorited_article(_article_id text, _user_id text = NULL)
RETURNS bool
AS $$
Expand All @@ -217,7 +226,7 @@ BEGIN
username,
bio,
image,
CASE WHEN _follower_id = NULL THEN
CASE WHEN _follower_id IS NULL THEN
FALSE
ELSE
real_medium.is_following(_id, _follower_id)
Expand All @@ -230,7 +239,7 @@ END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile(_article_id text, _follower_id text = NULL)
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_v1(_article_id text, _follower_id text = NULL)
RETURNS SETOF real_medium.tagged_article_with_author_profile
AS $$
BEGIN
Expand Down Expand Up @@ -259,7 +268,20 @@ END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug(_slug varchar(255), _follower_id text = NULL)
CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile(_article_id text, _follower_id text = NULL)
RETURNS SETOF real_medium.tagged_article_with_author_profile
AS $$
BEGIN
RETURN QUERY
SELECT
*
FROM
real_medium.get_article_with_author_profile_v1(_article_id, _follower_id);
END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug_v1(_slug varchar(255), _follower_id text = NULL)
RETURNS SETOF real_medium.tagged_article_with_author_profile
AS $$
DECLARE
Expand Down Expand Up @@ -296,6 +318,19 @@ END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug(_slug varchar(255), _follower_id text = NULL)
RETURNS SETOF real_medium.tagged_article_with_author_profile
AS $$
BEGIN
RETURN QUERY
SELECT
*
FROM
real_medium.get_article_with_author_profile_by_slug_v1(_slug, _follower_id);
END;
$$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION real_medium.get_feed_articles(_user_id text, _limit int = 20, _offset int = 0)
RETURNS SETOF real_medium.tagged_article_with_author_profile
AS $$
Expand Down Expand Up @@ -400,5 +435,3 @@ LANGUAGE plpgsql;
CREATE INDEX IF NOT EXISTS idx_createdat ON real_medium.articles(created_at DESC);

CREATE INDEX IF NOT EXISTS idx_tagname ON real_medium.tag_list(tag_name);