Skip to content

Commit

Permalink
Add temporary functionality to filter posts by Prohibition project ID (
Browse files Browse the repository at this point in the history
  • Loading branch information
radazen authored Sep 19, 2023
1 parent 9d8bc39 commit 49032d2
Show file tree
Hide file tree
Showing 7 changed files with 374 additions and 37 deletions.
72 changes: 72 additions & 0 deletions db/gen/coredb/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions db/queries/core/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,27 @@ ORDER BY
CASE WHEN NOT sqlc.arg('paging_forward')::bool THEN (posts.created_at, posts.id) END DESC
LIMIT sqlc.arg('limit');

-- name: PaginatePostsByContractIDAndProjectID :many
with valid_post_ids as (
SELECT distinct on (posts.id) posts.id
FROM posts
JOIN tokens on tokens.id = ANY(posts.token_ids)
and tokens.displayable
and tokens.deleted = false
and tokens.contract = sqlc.arg('contract_id')
and ('x' || lpad(substring(tokens.token_id, 1, 16), 16, '0'))::bit(64)::bigint / 1000000 = sqlc.arg('project_id_int')::int
WHERE sqlc.arg('contract_id') = ANY(posts.contract_ids)
AND posts.deleted = false
)
SELECT posts.* from posts
join valid_post_ids on posts.id = valid_post_ids.id
WHERE (posts.created_at, posts.id) < (sqlc.arg('cur_before_time'), sqlc.arg('cur_before_id'))
AND (posts.created_at, posts.id) > (sqlc.arg('cur_after_time'), sqlc.arg('cur_after_id'))
ORDER BY
CASE WHEN sqlc.arg('paging_forward')::bool THEN (posts.created_at, posts.id) END ASC,
CASE WHEN NOT sqlc.arg('paging_forward')::bool THEN (posts.created_at, posts.id) END DESC
LIMIT sqlc.arg('limit');

-- name: CountPostsByContractID :one
select count(*)
from posts
Expand Down
189 changes: 170 additions & 19 deletions graphql/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 49032d2

Please sign in to comment.