Skip to content

Commit

Permalink
Merge pull request #18 from PRX/feat/boostr_collection_flights
Browse files Browse the repository at this point in the history
Boostr collection external ids
  • Loading branch information
cavis authored Sep 16, 2024
2 parents f89d8cb + 3ce149b commit 4df4b02
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/query-jobs/boostr_impressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
* @param {ExportConfig} config
*/
export default async function job(config) {
const ds = process.env.BIGQUERY_DATASET;
const query = `
SELECT
FORMAT_TIMESTAMP("%m/%d/%Y", timestamp) AS Date,
external_id AS \`Ad Server Line\`,
count(*) AS Impressions
FROM ${process.env.BIGQUERY_DATASET}.dt_impressions
INNER JOIN ${process.env.BIGQUERY_DATASET}.flights ON (flight_id = id)
WHERE timestamp >= ?
AND timestamp < ?
AND is_duplicate = false
AND creative_id IS NOT NULL
AND integration_id IN (${config.integrationIds.join(", ")})
FORMAT_TIMESTAMP("%m/%d/%Y", i.timestamp) AS Date,
COALESCE(x.external_id, f.external_id) AS \`Ad Server Line\`,
COUNT(*) AS Impressions
FROM ${ds}.dt_impressions i
INNER JOIN ${ds}.flights f ON (i.flight_id = f.id)
LEFT JOIN ${ds}.flight_collection_external_ids x ON (f.id = x.flight_id AND i.feeder_podcast = x.podcast_id)
WHERE i.timestamp >= ?
AND i.timestamp < ?
AND i.is_duplicate = FALSE
AND i.creative_id IS NOT NULL
AND f.integration_id IN (${config.integrationIds.join(", ")})
GROUP BY Date, \`Ad Server Line\`
ORDER BY Date ASC, \`Ad Server Line\` ASC
`;
Expand Down

0 comments on commit 4df4b02

Please sign in to comment.