Skip to content

Commit

Permalink
delete composite types
Browse files Browse the repository at this point in the history
this removes the annoying step of undoing the composite type changes
whenever you run supabase regen types.
  • Loading branch information
sipec committed Jul 11, 2024
1 parent 3b887f3 commit df72b99
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 62 deletions.
39 changes: 22 additions & 17 deletions backend/supabase/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -576,23 +576,6 @@ or replace function public.creator_rank (uid text) returns integer language sql
where data->'creatorTraders'->'allTime' > (select data->'creatorTraders'->'allTime' from users where id = uid)
$function$;

create
or replace function public.get_groups_and_scores_from_user_seen_markets (uid text) returns setof group_with_score_and_bet_flag language sql as $function$
select (g.id, g.data, g.importance_score, false)::group_with_score_and_bet_flag
from
groups g
join group_contracts gc on g.id = gc.group_id
join user_contract_views ucv on gc.contract_id = ucv.contract_id
where ucv.user_id = uid and ucv.page_views > 0
union
select (g.id, g.data, g.importance_score, true)::group_with_score_and_bet_flag
from
groups g
join group_contracts gc on g.id = gc.group_id
join contract_bets cb on gc.contract_id = cb.contract_id
where cb.user_id = uid
$function$;

create
or replace function public.creator_leaderboard (limit_n integer) returns table (
user_id text,
Expand Down Expand Up @@ -744,6 +727,28 @@ from (
where (politics is false or is_politics = politics)
limit count $function$;

create
or replace function public.get_groups_and_scores_from_user_seen_markets (uid text) returns table (
id text,
data jsonb,
importance_score numeric,
has_bet boolean
) language sql as $function$
select (g.id, g.data, g.importance_score, false)
from
groups g
join group_contracts gc on g.id = gc.group_id
join user_contract_views ucv on gc.contract_id = ucv.contract_id
where ucv.user_id = uid and ucv.page_views > 0
union
select (g.id, g.data, g.importance_score, true)
from
groups g
join group_contracts gc on g.id = gc.group_id
join contract_bets cb on gc.contract_id = cb.contract_id
where cb.user_id = uid
$function$;

create
or replace function public.get_noob_questions () returns setof contracts language sql as $function$with newbs as (
select id
Expand Down
16 changes: 0 additions & 16 deletions backend/supabase/tv.sql

This file was deleted.

43 changes: 14 additions & 29 deletions common/src/supabase/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,12 @@ export type Database = {
Args: {
uid: string
}
Returns: Database['public']['CompositeTypes']['group_with_score_and_bet_flag'][]
Returns: {
id: string
data: Json
importance_score: number
has_bet: boolean
}[]
}
get_love_question_answers_and_lovers: {
Args: {
Expand Down Expand Up @@ -3824,35 +3829,15 @@ export type Database = {
status_type: 'new' | 'under review' | 'resolved' | 'needs admin'
}
CompositeTypes: {
contract_ids: {
contract_id: string
}
contract_score: {
contract_id: string
}
group_with_bet_flag: {
id: string
data: Json
has_bet: boolean
}
group_with_score_and_bet_flag: {
id: string
data: Json
importance_score: number
has_bet: boolean
}
jsonb_data: {
data: Json
}
love_question_with_count_type: {
id: number
creator_id: string
created_time: string
question: string
importance_score: number
answer_type: string
multiple_choice_options: Json
answer_count: number
id: number | null
creator_id: string | null
created_time: string | null
question: string | null
importance_score: number | null
answer_type: string | null
multiple_choice_options: Json | null
answer_count: number | null
}
other_lover_answers_type: {
question_id: number | null
Expand Down

0 comments on commit df72b99

Please sign in to comment.