Skip to content

Commit

Permalink
Merge pull request #174 from novaforgood/dev
Browse files Browse the repository at this point in the history
Deploy prod
  • Loading branch information
legitmaxwu committed May 15, 2023
2 parents e0b9358 + 15322f7 commit 163175f
Show file tree
Hide file tree
Showing 46 changed files with 6,170 additions and 39 deletions.
41 changes: 41 additions & 0 deletions hasura/metadata/databases/mentorcenter/tables/public_block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
table:
name: block
schema: public
object_relationships:
- name: blocked_profile
using:
foreign_key_constraint_on: blocked_profile_id
- name: blocker_profile
using:
foreign_key_constraint_on: blocker_profile_id
insert_permissions:
- role: user
permission:
check:
_or:
- blocker_profile:
user_id:
_eq: X-Hasura-User-Id
columns:
- blocked_profile_id
- blocker_profile_id
select_permissions:
- role: user
permission:
columns:
- id
- blocker_profile_id
- blocked_profile_id
filter:
_or:
- blocker_profile:
user_id:
_eq: X-Hasura-User-Id
delete_permissions:
- role: user
permission:
filter:
_or:
- blocker_profile:
user_id:
_eq: X-Hasura-User-Id
24 changes: 24 additions & 0 deletions hasura/metadata/databases/mentorcenter/tables/public_profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ object_relationships:
using:
foreign_key_constraint_on: user_id
array_relationships:
- name: blocked_profiles
using:
foreign_key_constraint_on:
column: blocker_profile_id
table:
name: block
schema: public
- name: blocker_profiles
using:
foreign_key_constraint_on:
column: blocked_profile_id
table:
name: block
schema: public
- name: flattened_profile_roles
using:
manual_configuration:
Expand Down Expand Up @@ -57,6 +71,14 @@ array_relationships:
remote_table:
name: past_day_unread_messages_count
schema: public
computed_fields:
- name: blocked_by_user
definition:
function:
name: profile_blocked_by_user
schema: public
session_argument: hasura_session
comment: Is the profile blocked by the user?
insert_permissions:
- role: user
permission:
Expand Down Expand Up @@ -101,6 +123,8 @@ select_permissions:
- last_read_announcement_id
- space_id
- user_id
computed_fields:
- blocked_by_user
filter:
_and:
- space:
Expand Down
1 change: 1 addition & 0 deletions hasura/metadata/databases/mentorcenter/tables/tables.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- "!include public_announcement.yaml"
- "!include public_block.yaml"
- "!include public_chat_intro.yaml"
- "!include public_chat_intro_data.yaml"
- "!include public_chat_message.yaml"
Expand Down
31 changes: 31 additions & 0 deletions hasura/migrations/mentorcenter/1684185864247_squashed/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
-- RETURNS boolean
-- LANGUAGE sql
-- STABLE
-- AS $function$
-- SELECT EXISTS (
-- SELECT 1
-- FROM block
-- JOIN profile ON block.blocker_profile_id = profile.id
-- WHERE block.blocker_profile_id = profile.id
-- AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
-- );
-- $function$;

-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION profile_blocked_by_user(profile_row profile, hasura_session json)
-- RETURNS boolean AS $$
-- SELECT EXISTS (
-- SELECT 1
-- FROM block
-- JOIN profile ON block.blocker_profile_id = profile.id
-- WHERE block.blocker_profile_id = profile_row.id
-- AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
-- );
-- $$ LANGUAGE sql STABLE;

DROP TABLE "public"."block";
17 changes: 17 additions & 0 deletions hasura/migrations/mentorcenter/1684185864247_squashed/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

CREATE TABLE "public"."block" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "blocker_profile_id" uuid NOT NULL, "blocked_profile_id" uuid NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("blocker_profile_id") REFERENCES "public"."profile"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("blocked_profile_id") REFERENCES "public"."profile"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("blocker_profile_id", "blocked_profile_id"));COMMENT ON TABLE "public"."block" IS E'Each row represents a profile blocking another profile';
CREATE EXTENSION IF NOT EXISTS pgcrypto;

CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
RETURNS boolean
LANGUAGE sql
STABLE
AS $function$
SELECT EXISTS (
SELECT 1
FROM block
JOIN profile ON block.blocker_profile_id = profile.id
WHERE block.blocker_profile_id = profile.id
AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
);
$function$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
-- RETURNS boolean
-- LANGUAGE sql
-- STABLE
-- AS $function$
-- SELECT EXISTS (
-- SELECT 1
-- FROM block
-- JOIN profile ON block.blocker_profile_id = profile.id
-- WHERE block.blocker_profile_id = profile.id
-- AND block.blocked_profile_id = profile.id
-- AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
-- );
-- $function$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
RETURNS boolean
LANGUAGE sql
STABLE
AS $function$
SELECT EXISTS (
SELECT 1
FROM block
JOIN profile ON block.blocker_profile_id = profile.id
WHERE block.blocker_profile_id = profile.id
AND block.blocked_profile_id = profile.id
AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
);
$function$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
-- RETURNS boolean
-- LANGUAGE sql
-- STABLE
-- AS $function$
-- SELECT EXISTS (
-- SELECT 1
-- FROM block
-- JOIN profile ON block.blocker_profile_id = profile.id
-- WHERE block.blocker_profile_id = profile.id
-- AND block.blocked_profile_id = profile_row.id
-- AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
-- );
-- $function$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE OR REPLACE FUNCTION public.profile_blocked_by_user(profile_row profile, hasura_session json)
RETURNS boolean
LANGUAGE sql
STABLE
AS $function$
SELECT EXISTS (
SELECT 1
FROM block
JOIN profile ON block.blocker_profile_id = profile.id
WHERE block.blocker_profile_id = profile.id
AND block.blocked_profile_id = profile_row.id
AND profile.user_id = hasura_session ->> 'x-hasura-user-id'
);
$function$;
Loading

1 comment on commit 163175f

@vercel
Copy link

@vercel vercel bot commented on 163175f May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.