From a1e4f0ad87b9ae716d9839ff7a0464bfa4c7ac9d Mon Sep 17 00:00:00 2001 From: 0xthrpw <0xthrpw@gmail.com> Date: Fri, 2 Aug 2024 02:01:44 -0400 Subject: [PATCH] migration fixes --- .../create_view__join__efp_leaderboard.sql | 0 ..._view__events__efp_leaderboard_mutuals.sql | 8 +++--- src/database/generated/index.ts | 27 +++++++++++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) rename db/{schema/050__views/003/join__efp_leaderboard => queries/api/v1/leaderboard/ranked}/create_view__join__efp_leaderboard.sql (100%) rename db/schema/050__views/{003 => 004}/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql (77%) diff --git a/db/schema/050__views/003/join__efp_leaderboard/create_view__join__efp_leaderboard.sql b/db/queries/api/v1/leaderboard/ranked/create_view__join__efp_leaderboard.sql similarity index 100% rename from db/schema/050__views/003/join__efp_leaderboard/create_view__join__efp_leaderboard.sql rename to db/queries/api/v1/leaderboard/ranked/create_view__join__efp_leaderboard.sql diff --git a/db/schema/050__views/003/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql b/db/schema/050__views/004/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql similarity index 77% rename from db/schema/050__views/003/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql rename to db/schema/050__views/004/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql index 24d0761..36d4048 100644 --- a/db/schema/050__views/003/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql +++ b/db/schema/050__views/004/events__efp_leaderboard_mutuals/create_view__events__efp_leaderboard_mutuals.sql @@ -4,14 +4,14 @@ ------------------------------------------------------------------------------- CREATE OR REPLACE VIEW PUBLIC.view__events__efp_leaderboard_mutuals AS -SELECT hexlify(r.record_data) as leader, COUNT(r.record_data) as mutuals +SELECT public.hexlify(r.record_data) as leader, COUNT(r.record_data) as mutuals FROM public.view__join__efp_list_records_with_nft_manager_user_tags r -WHERE hexlify(r.record_data) <> r.user +WHERE public.hexlify(r.record_data) <> r.user AND EXISTS ( SELECT 1 FROM public.view__join__efp_list_records_with_nft_manager_user_tags r2 - WHERE hexlify(r2.record_data) = r.user - AND hexlify(r.record_data) = r2.user + WHERE public.hexlify(r2.record_data) = r.user + AND public.hexlify(r.record_data) = r2.user ) GROUP BY leader; diff --git a/src/database/generated/index.ts b/src/database/generated/index.ts index beb2205..982bab1 100644 --- a/src/database/generated/index.ts +++ b/src/database/generated/index.ts @@ -44,12 +44,13 @@ export interface EfpAccountMetadata { export interface EfpLeaderboard { address: string avatar: string | null - blocks: Int8 | null + blocks: Generated created_at: Generated - followers: Int8 | null - following: Int8 | null - mutuals: Int8 | null - name: string + followers: Generated + following: Generated + mutuals: Generated + mutuals_rank: Int8 | null + name: string | null updated_at: Generated } @@ -177,6 +178,11 @@ export interface ViewEventsEfpContracts { owner: string | null } +export interface ViewEventsEfpLeaderboardMutuals { + leader: string | null + mutuals: Int8 | null +} + export interface ViewEventsEfpListMetadata { block_number: Int8 | null chain_id: Int8 | null @@ -273,6 +279,15 @@ export interface ViewEventsLatestRecordTags { tag: string | null } +export interface ViewJoinEfpLeaderboard { + address: string | null + blocks: Int8 | null + followers: Int8 | null + following: Int8 | null + mutuals: Int8 | null + mutuals_rank: Int8 | null +} + export interface ViewJoinEfpListRecordsWithNftManagerUserTags { has_block_tag: boolean | null has_mute_tag: boolean | null @@ -325,6 +340,7 @@ export interface DB { view__events__efp_account_metadata: ViewEventsEfpAccountMetadata view__events__efp_accounts_with_primary_list: ViewEventsEfpAccountsWithPrimaryList view__events__efp_contracts: ViewEventsEfpContracts + view__events__efp_leaderboard_mutuals: ViewEventsEfpLeaderboardMutuals view__events__efp_list_metadata: ViewEventsEfpListMetadata view__events__efp_list_nfts: ViewEventsEfpListNfts view__events__efp_list_ops: ViewEventsEfpListOps @@ -333,6 +349,7 @@ export interface DB { view__events__efp_list_records: ViewEventsEfpListRecords view__events__efp_list_storage_locations: ViewEventsEfpListStorageLocations view__events__latest_record_tags: ViewEventsLatestRecordTags + view__join__efp_leaderboard: ViewJoinEfpLeaderboard view__join__efp_list_records_with_nft_manager_user_tags: ViewJoinEfpListRecordsWithNftManagerUserTags view__join__efp_list_records_with_tags: ViewJoinEfpListRecordsWithTags view__latest_follows: ViewLatestFollows