Skip to content

Commit 5074d09

Browse files
Update schema, fix test
1 parent f7de00c commit 5074d09

3 files changed

Lines changed: 64 additions & 12 deletions

File tree

api/dbv1/models.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ddl/migrations/0160_artist_coin_pools.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
DROP TABLE IF EXISTS artist_coin_pools;
21
CREATE TABLE IF NOT EXISTS artist_coin_pools (
32
address TEXT NOT NULL PRIMARY KEY,
43
base_mint TEXT NOT NULL,

sql/01_schema.sql

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
-- PostgreSQL database dump
33
--
44

5-
6-
-- Dumped from database version 17.7 (Debian 17.7-3.pgdg13+1)
7-
-- Dumped by pg_dump version 17.7 (Debian 17.7-3.pgdg13+1)
5+
-- Dumped from database version 17.5 (Debian 17.5-1.pgdg120+1)
6+
-- Dumped by pg_dump version 17.5 (Debian 17.5-1.pgdg120+1)
87

98
SET statement_timeout = 0;
109
SET lock_timeout = 0;
@@ -5862,6 +5861,28 @@ CREATE TABLE public.api_metrics_apps (
58625861
);
58635862

58645863

5864+
--
5865+
-- Name: api_metrics_apps_unique; Type: TABLE; Schema: public; Owner: -
5866+
--
5867+
5868+
CREATE TABLE public.api_metrics_apps_unique (
5869+
date date NOT NULL,
5870+
app_name character varying(255) NOT NULL,
5871+
hll_sketch bytea,
5872+
total_count bigint DEFAULT 0 NOT NULL,
5873+
unique_count bigint DEFAULT 0 NOT NULL,
5874+
created_at timestamp without time zone DEFAULT now() NOT NULL,
5875+
updated_at timestamp without time zone DEFAULT now() NOT NULL
5876+
);
5877+
5878+
5879+
--
5880+
-- Name: TABLE api_metrics_apps_unique; Type: COMMENT; Schema: public; Owner: -
5881+
--
5882+
5883+
COMMENT ON TABLE public.api_metrics_apps_unique IS 'Stores HLL sketches for tracking unique users per application. app_name stores the identifier (api_key if present, otherwise app_name from request).';
5884+
5885+
58655886
--
58665887
-- Name: api_metrics_counts; Type: TABLE; Schema: public; Owner: -
58675888
--
@@ -6232,21 +6253,21 @@ CREATE VIEW public.artist_coin_prices AS
62326253
SELECT artist_coins.mint,
62336254
damm_v2.price AS damm_v2_price,
62346255
dbc.price AS dbc_price,
6235-
stats.price AS stats_price,
62366256
pools.price_usd AS pools_price_usd,
6237-
COALESCE(damm_v2.price, dbc.price, stats.price, pools.price_usd) AS price
6257+
stats.price AS stats_price,
6258+
COALESCE(damm_v2.price, dbc.price, pools.price_usd, stats.price) AS price
62386259
FROM ((((public.artist_coins
62396260
LEFT JOIN dbc ON (((artist_coins.mint)::text = (dbc.mint)::text)))
62406261
LEFT JOIN damm_v2 ON (((artist_coins.mint)::text = (damm_v2.mint)::text)))
6241-
LEFT JOIN public.artist_coin_stats stats ON ((stats.mint = (artist_coins.mint)::text)))
6242-
LEFT JOIN public.artist_coin_pools pools ON ((pools.base_mint = (artist_coins.mint)::text)));
6262+
LEFT JOIN public.artist_coin_pools pools ON ((pools.base_mint = (artist_coins.mint)::text)))
6263+
LEFT JOIN public.artist_coin_stats stats ON ((stats.mint = (artist_coins.mint)::text)));
62436264

62446265

62456266
--
62466267
-- Name: VIEW artist_coin_prices; Type: COMMENT; Schema: public; Owner: -
62476268
--
62486269

6249-
COMMENT ON VIEW public.artist_coin_prices IS 'View that provides artist coin prices using DAMM V2 pool if available, DBC pools if not and still applicable, stats table if available, and artist_coin_pools.price_usd as final fallback. Makes use of the price of the quote token (AUDIO) from Birdeye if using a pool.';
6270+
COMMENT ON VIEW public.artist_coin_prices IS 'View that provides artist coin prices using DAMM V2 pool if available, DBC pools if not and still applicable, artist_coin_pools.price_usd as fallback, and artist_coin_stats.price as final fallback (primarily for AUDIO and other tokens without pools). Makes use of the price of the quote token (AUDIO) from Birdeye if using a pool.';
62506271

62516272

62526273
--
@@ -9425,6 +9446,14 @@ ALTER TABLE ONLY public.api_metrics_apps
94259446
ADD CONSTRAINT api_metrics_apps_pkey PRIMARY KEY (date, api_key, app_name);
94269447

94279448

9449+
--
9450+
-- Name: api_metrics_apps_unique api_metrics_apps_unique_pkey; Type: CONSTRAINT; Schema: public; Owner: -
9451+
--
9452+
9453+
ALTER TABLE ONLY public.api_metrics_apps_unique
9454+
ADD CONSTRAINT api_metrics_apps_unique_pkey PRIMARY KEY (date, app_name);
9455+
9456+
94289457
--
94299458
-- Name: api_metrics_counts api_metrics_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
94309459
--
@@ -10731,6 +10760,20 @@ CREATE INDEX idx_api_metrics_apps_app_name ON public.api_metrics_apps USING btre
1073110760
CREATE INDEX idx_api_metrics_apps_date ON public.api_metrics_apps USING btree (date);
1073210761

1073310762

10763+
--
10764+
-- Name: idx_api_metrics_apps_unique_app_name; Type: INDEX; Schema: public; Owner: -
10765+
--
10766+
10767+
CREATE INDEX idx_api_metrics_apps_unique_app_name ON public.api_metrics_apps_unique USING btree (app_name);
10768+
10769+
10770+
--
10771+
-- Name: idx_api_metrics_apps_unique_date; Type: INDEX; Schema: public; Owner: -
10772+
--
10773+
10774+
CREATE INDEX idx_api_metrics_apps_unique_date ON public.api_metrics_apps_unique USING btree (date);
10775+
10776+
1073410777
--
1073510778
-- Name: idx_api_metrics_counts_date; Type: INDEX; Schema: public; Owner: -
1073610779
--
@@ -12534,4 +12577,3 @@ ALTER TABLE ONLY public.users
1253412577
-- PostgreSQL database dump complete
1253512578
--
1253612579

12537-

0 commit comments

Comments
 (0)