Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Date tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
strum3nt committed Jul 4, 2020
1 parent 004bf58 commit 706ab4a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ const isAdminOrUser = (user) => {

const citationQuery = `(
ARRAY(
SELECT DISTINCT main.case_citations.citation
SELECT DISTINCT TRIM (trailing '\n' from main.case_citations.citation)
FROM main.case_citations
WHERE main.case_citations.case_id = m.id
)
Expand All @@ -434,14 +434,24 @@ const isAdminOrUser = (user) => {
WHERE m.court_id = main.courts.id
) AS court`;

const dateQuery = `(
SELECT TO_CHAR(
main.cases.case_date, 'DD Month YYYY'
) as date
FROM main.cases
WHERE m.id = main.cases.id
) AS date`;

const accColumn = (facetId, colName, facetName) => `
LEFT JOIN LATERAL (
SELECT
json_agg(item) as ${colName}
FROM (
SELECT
funnel.facet_value_metadata.user_id,
funnel.facet_value_metadata.date_recorded,
TO_CHAR(
funnel.facet_value_metadata.date_recorded, 'HH24:MI DD FMMonth FMYYYY'
) as date_recorded,
funnel.boolean_facet_values.value as boolean_value,
funnel.boolean_facet_values.not_applicable as boolean_not_applicable,
funnel.boolean_facet_values.unsure as boolean_unsure,
Expand Down Expand Up @@ -515,7 +525,7 @@ const isAdminOrUser = (user) => {
break;

case 'date':
s.push('case_date');
s.push(dateQuery);
break;

case 'citation':
Expand Down

0 comments on commit 706ab4a

Please sign in to comment.