Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging catch up #19

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions db/schema/020__tables/001/create_table__efp_poap_links.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
$$;
Expand Down
1 change: 1 addition & 0 deletions environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
11 changes: 10 additions & 1 deletion src/database/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ export interface EfpLists {
user: string
}

export interface EfpPoapLinks {
claimant: string | null
claimed: boolean
created_at: Generated<Timestamp | null>
link: string
updated_at: Generated<Timestamp | null>
}

export interface EfpRecommended {
address: string
avatar: string | null
Expand All @@ -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<Timestamp | null>
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion src/pubsub/publisher/event-interleaver.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -149,7 +150,7 @@ export class EventInterleaver implements EventPublisher, EventSubscriber {

async #processQueue(): Promise<void> {
const now = new Date()
const batchSize = 1000
const batchSize = env.BATCH_SIZE
// Muted by user
// biome-ignore lint/nursery/noEvolvingTypes: <explanation>
let batch = []
Expand Down