From 5006c9196693c989d4a7ac53f57f6d2c1f57b430 Mon Sep 17 00:00:00 2001 From: stevenleggdfe <51697598+stevenleggdfe@users.noreply.github.com> Date: Mon, 17 Feb 2020 14:47:35 +0000 Subject: [PATCH] Repoint vacancies-published.sql --- bigquery/vacancies-published.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bigquery/vacancies-published.sql b/bigquery/vacancies-published.sql index 9b00963f09c..5b51dbf9629 100644 --- a/bigquery/vacancies-published.sql +++ b/bigquery/vacancies-published.sql @@ -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