Skip to content

Commit

Permalink
Repoint vacancies-published.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenleggdfe authored Feb 17, 2020
1 parent 11b1678 commit 5006c91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bigquery/vacancies-published.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ WITH
DATE_ADD(year,INTERVAL 8 MONTH)) AS academic_year #converts the month into the corresponding academic year, storing this as the 1st September at the beginning of that academic year (the precise format doesn't matter; we just need a consistent way to represent the academic year so that the PARTITION BY above works)
FROM (
SELECT
CAST(TIMESTAMP_TRUNC(publish_on,MONTH) AS DATE) AS month, #use the first day of the month containing publish_on to represent the month (standard in data studio)
CAST(TIMESTAMP_TRUNC(publish_on,YEAR) AS DATE) AS year #use the first day of the year containing publish_on to represent the year (standard in data studio)
DATE_TRUNC(PARSE_DATE("%e %B %E4Y",publish_on),MONTH) AS month, #use the first day of the month containing publish_on to represent the month (standard in data studio)
DATE_TRUNC(PARSE_DATE("%e %B %E4Y",publish_on),YEAR) AS year #use the first day of the year containing publish_on to represent the year (standard in data studio)
FROM
`teacher-vacancy-service.production_dataset.vacancies`
`teacher-vacancy-service.production_dataset.vacancy`
WHERE
status NOT IN ("trashed",
"deleted",
"draft") #excludes vacancies which were never published, or which were published and then subsequently deleted
AND publish_on IS NOT NULL #also excludes vacancies which were never published (to be safe)
AND publish_on < CURRENT_TIMESTAMP() ) #excludes vacancies which have been published but are not yet visible on the site because their publication date is in the future
AND PARSE_DATE("%e %B %E4Y",publish_on) <= CURRENT_DATE() ) #excludes vacancies which have been published but are not yet visible on the site because their publication date is in the future
GROUP BY
month,
year
Expand Down

0 comments on commit 5006c91

Please sign in to comment.