Skip to content
Open
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
28 changes: 28 additions & 0 deletions db_schema/migrations/12_apple_aggregated_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
INSERT INTO migrations (migration_id, migration_name) VALUES (12, 'apple aggregated data');

-- aggreagated values per episode coming from the apple trends api
CREATE TABLE IF NOT EXISTS appleTrendsEpisodeListenersAggregated (
account_id INTEGER NOT NULL,
episode_id BIGINT NOT NULL,
date_start DATE NOT NULL,
date_end DATE NOT NULL,
atl_playscount INTEGER NOT NULL,
atl_totaltimelistened BIGINT NOT NULL,
atl_uniqueengagedlistenerscount INTEGER NOT NULL,
atl_uniquelistenerscount INTEGER NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY (account_id, episode_id, date_start, date_end)
);

-- aggreagated values per podcast coming from the apple trends api
CREATE TABLE IF NOT EXISTS appleTrendsPodcastListenersAggregated (
account_id INTEGER NOT NULL,
date_start DATE NOT NULL,
date_end DATE NOT NULL,
atl_playscount INTEGER NOT NULL,
atl_totaltimelistened BIGINT NOT NULL,
atl_uniqueengagedlistenerscount INTEGER NOT NULL,
atl_uniquelistenerscount INTEGER NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY (account_id, date_start, date_end)
);
29 changes: 28 additions & 1 deletion db_schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS migrations (
-- -----------------------------------------
-- IMPORTANT: this is the schema version
-- ID has to be incremented for each change
INSERT INTO migrations (migration_id, migration_name) VALUES (11, 'anchor episodesPage');
INSERT INTO migrations (migration_id, migration_name) VALUES (12, 'apple aggregated data');
-- -----------------------------------------

CREATE TABLE IF NOT EXISTS events (
Expand Down Expand Up @@ -197,6 +197,20 @@ CREATE TABLE IF NOT EXISTS appleTrendsEpisodeListeners (
PRIMARY KEY (account_id, episode_id, atl_date)
);

-- aggreagated values per episode coming from the apple trends api
CREATE TABLE IF NOT EXISTS appleTrendsEpisodeListenersAggregated (
account_id INTEGER NOT NULL,
episode_id BIGINT NOT NULL,
date_start DATE NOT NULL,
date_end DATE NOT NULL,
atl_playscount INTEGER NOT NULL,
atl_totaltimelistened BIGINT NOT NULL,
atl_uniqueengagedlistenerscount INTEGER NOT NULL,
atl_uniquelistenerscount INTEGER NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY (account_id, episode_id, date_start, date_end)
);

-- listeners values per day and per podcast coming from the apple trends api
CREATE TABLE IF NOT EXISTS appleTrendsPodcastListeners (
account_id INTEGER NOT NULL,
Expand All @@ -208,6 +222,19 @@ CREATE TABLE IF NOT EXISTS appleTrendsPodcastListeners (
PRIMARY KEY (account_id, atl_date)
);

-- aggreagated values per podcast coming from the apple trends api
CREATE TABLE IF NOT EXISTS appleTrendsPodcastListenersAggregated (
account_id INTEGER NOT NULL,
date_start DATE NOT NULL,
date_end DATE NOT NULL,
atl_playscount INTEGER NOT NULL,
atl_totaltimelistened BIGINT NOT NULL,
atl_uniqueengagedlistenerscount INTEGER NOT NULL,
atl_uniquelistenerscount INTEGER NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY (account_id, date_start, date_end)
);

-- store totallistened time for followers and nonfollowers
CREATE TABLE IF NOT EXISTS appleTrendsPodcastListeningTimeFollowerState (
account_id INTEGER NOT NULL,
Expand Down