Skip to content

Commit 3b88123

Browse files
committed
fix(top): Remove previous entries before syncing new
1 parent 8ed464f commit 3b88123

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

scripts/poll-top-charts.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ async function storeTopPodcasts(
113113
ON CONFLICT (id) DO NOTHING
114114
`;
115115

116+
await sql`
117+
DELETE FROM top_podcasts
118+
WHERE country_id = ${locale} AND genre_id = 0
119+
`;
120+
116121
let stored = 0;
117122
let newPodcasts = 0;
118123

@@ -128,7 +133,9 @@ async function storeTopPodcasts(
128133
}
129134

130135
let [podcast] = await sql`
131-
SELECT id FROM podcasts WHERE feed_url = ${p.feed} LIMIT 1
136+
SELECT id FROM podcasts
137+
WHERE itunes_id = ${p.itunesId} OR feed_url = ${p.feed}
138+
LIMIT 1
132139
`;
133140

134141
const isNew = !podcast;

0 commit comments

Comments
 (0)