Skip to content

Commit

Permalink
fix query and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rotorsoft authored and ilijabojanovic committed Dec 3, 2024
1 parent 193a8fc commit 5332a18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions libs/model/src/thread/GetThreads.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function GetThreads(): Query<typeof schemas.GetThreads> {
'id', T.id,
'name', T.name,
'description', T.description,
'communityId', T.community_id,
'community_id', T.community_id,
'telegram', T.telegram
) as topic,
json_build_object(
Expand Down Expand Up @@ -156,9 +156,10 @@ export function GetThreads(): Query<typeof schemas.GetThreads> {
TT.id as thread_id,
json_agg(json_strip_nulls(json_build_object(
'id', R.id,
'address_id', R.address_id,
'reaction', R.reaction,
'updated_at', R.updated_at::text,
'calculated_voting_weight', R.calculated_voting_weight,
'calculated_voting_weight', R.calculated_voting_weight::text,
'profile_name', U.profile->>'name',
'avatar_url', U.profile->>'avatar_url',
'address', A.address,
Expand All @@ -184,7 +185,12 @@ export function GetThreads(): Query<typeof schemas.GetThreads> {
'thread_id', TT.id,
'content_id', CA.content_id,
'start_time', CON.start_time,
'end_time', CON.end_time
'end_time', CON.end_time,
'ContestManager', json_build_object(
'name', CM.name,
'cancelled', CM.cancelled,
'interval', CM.interval
)
))) as "associatedContests"
FROM "Contests" CON
JOIN "ContestManagers" CM ON CM.contest_address = CON.contest_address
Expand Down
3 changes: 2 additions & 1 deletion libs/schemas/src/queries/thread.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ export const ThreadView = Thread.extend({
Reaction: ReactionView.nullish(),
collaborators: AddressView.array().nullish(),
reactions: ReactionView.array().nullish(),
associatedContests: z.array(ContestView).optional(),
associatedContests: z.array(ContestView).nullish(),
topic: TopicView.optional(),
topic_id: PG_INT.optional(),
ContestActions: z.array(ContestActionView).optional(),
Comments: z.array(CommentView).optional(),
ThreadVersionHistories: z.array(ThreadVersionHistoryView).nullish(),
search: z.union([z.string(), z.record(z.any())]).nullish(),
});

export const OrderByQueriesKeys = z.enum([
Expand Down

0 comments on commit 5332a18

Please sign in to comment.