diff --git a/db/schema/020__tables/001/create_table__efp_poap_links.sql b/db/schema/020__tables/001/create_table__efp_poap_links.sql new file mode 100644 index 0000000..0371702 --- /dev/null +++ b/db/schema/020__tables/001/create_table__efp_poap_links.sql @@ -0,0 +1,31 @@ +-- migrate:up +------------------------------------------------------------------------------- +-- Table: ens_metadata +------------------------------------------------------------------------------- +CREATE TABLE + public.efp_poap_links ( + "link" TEXT NOT NULL, + "claimed" BOOLEAN NOT NULL, + "claimant" TEXT, + created_at TIMESTAMP + WITH + TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP + WITH + TIME ZONE DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY ("link") + ); + +CREATE TRIGGER + update_efp_poap_links_updated_at BEFORE +UPDATE + ON public.efp_poap_links FOR EACH ROW +EXECUTE + FUNCTION public.update_updated_at_column(); + +-- migrate:down +------------------------------------------------------------------------------- +-- Undo Table: efp_poap_links +------------------------------------------------------------------------------- +DROP TABLE + IF EXISTS public.efp_poap_links CASCADE; \ No newline at end of file diff --git a/db/schema/030__functions/002/create_function__handle_contract_event__Transfer.sql b/db/schema/030__functions/002/create_function__handle_contract_event__Transfer.sql index 05160fd..4bfbf65 100644 --- a/db/schema/030__functions/002/create_function__handle_contract_event__Transfer.sql +++ b/db/schema/030__functions/002/create_function__handle_contract_event__Transfer.sql @@ -72,18 +72,18 @@ BEGIN ELSE -- Update existing row - UPDATE public.efp_list_nfts AS nft - SET nft.owner = normalized_to_address - WHERE nft.chain_id = p_chain_id - AND nft.contract_address = normalized_contract_address - AND nft.token_id = p_token_id; + UPDATE public.efp_list_nfts + SET owner = normalized_to_address + WHERE chain_id = p_chain_id + AND contract_address = normalized_contract_address + AND token_id = p_token_id; -- Update existing row - UPDATE public.efp_lists AS l - SET l.owner = normalized_to_address - WHERE l.nft_chain_id = p_chain_id - AND l.nft_contract_address = normalized_contract_address - AND l.token_id = p_token_id; + UPDATE public.efp_lists + SET owner = normalized_to_address + WHERE nft_chain_id = p_chain_id + AND nft_contract_address = normalized_contract_address + AND token_id = p_token_id; END IF; END; $$; diff --git a/environment.d.ts b/environment.d.ts index 67c11e3..5ecd5c2 100644 --- a/environment.d.ts +++ b/environment.d.ts @@ -22,6 +22,7 @@ interface EnvironmentVariables { readonly QUIKNODE_PREFIX: string readonly SNITCH_ID: string readonly START_BLOCK: string + readonly BATCH_SIZE: number } declare module 'bun' { diff --git a/src/database/generated/index.ts b/src/database/generated/index.ts index 6dd677f..69cc116 100644 --- a/src/database/generated/index.ts +++ b/src/database/generated/index.ts @@ -125,6 +125,14 @@ export interface EfpLists { user: string } +export interface EfpPoapLinks { + claimant: string | null + claimed: boolean + created_at: Generated + link: string + updated_at: Generated +} + export interface EfpRecommended { address: string avatar: string | null @@ -143,7 +151,7 @@ export interface EnsMetadata { errors: string | null fresh: Int8 | null name: string - records: string[] | null + records: Json | null resolver: string | null updated_at: Generated } @@ -409,6 +417,7 @@ export interface DB { efp_list_record_tags: EfpListRecordTags efp_list_records: EfpListRecords efp_lists: EfpLists + efp_poap_links: EfpPoapLinks efp_recommended: EfpRecommended ens_metadata: EnsMetadata events: Events diff --git a/src/env.ts b/src/env.ts index 4600365..2aac248 100644 --- a/src/env.ts +++ b/src/env.ts @@ -19,6 +19,7 @@ export const env = Object.freeze({ CHAIN_ID: getEnvVariable('CHAIN_ID'), SNITCH_ID: getEnvVariable('SNITCH_ID'), START_BLOCK: getEnvVariable('START_BLOCK'), + BATCH_SIZE: getEnvVariable('BATCH_SIZE'), EFP_CONTRACTS: { ACCOUNT_METADATA: getEnvVariable('EFP_CONTRACT_ACCOUNT_METADATA'), LIST_MINTER: getEnvVariable('EFP_CONTRACT_LINT_MINTER'), diff --git a/src/pubsub/publisher/event-interleaver.ts b/src/pubsub/publisher/event-interleaver.ts index 170f5f5..4ebd0cb 100644 --- a/src/pubsub/publisher/event-interleaver.ts +++ b/src/pubsub/publisher/event-interleaver.ts @@ -1,4 +1,5 @@ import BinaryHeap from 'heap-js' +import { env } from '#/env' import { logger } from '#/logger' import { type Event, compareEvents } from '#/pubsub/event' import type { EventSubscriber } from '#/pubsub/subscriber/interface' @@ -149,7 +150,7 @@ export class EventInterleaver implements EventPublisher, EventSubscriber { async #processQueue(): Promise { const now = new Date() - const batchSize = 1000 + const batchSize = env.BATCH_SIZE // Muted by user // biome-ignore lint/nursery/noEvolvingTypes: let batch = []