From 991690e86d8764e1ae06a59b4801102ffdd3ddf7 Mon Sep 17 00:00:00 2001 From: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:08:24 -0400 Subject: [PATCH 1/3] fix date parsing to output utc --- .../src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx b/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx index 2f4e464b2670c..3086c25bfa5b1 100644 --- a/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx +++ b/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx @@ -35,9 +35,9 @@ export default function RetainEmlMenuItem(props: RetainEmlMenuItemProps) { if (Number.isNaN(date.getTime())) { date = new Date(d); } - const day = date.getDate(); - const month = date.getMonth() + 1; // months are labelled 0-11; - const year = date.getFullYear(); + const day = date.getUTCDate(); + const month = date.getUTCMonth() + 1; // months are labelled 0-11; + const year = date.getUTCFullYear(); return `${year}-${month}-${day}`; }); } catch (error) { From 377eb269fe72c686d73f31520a44cce9f19e1886 Mon Sep 17 00:00:00 2001 From: cccs-RyanK Date: Fri, 26 Jul 2024 10:21:49 -0400 Subject: [PATCH 2/3] add limit to retention query --- .../src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx b/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx index 3086c25bfa5b1..283437284119f 100644 --- a/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx +++ b/superset-frontend/src/cccs-viz/plugins/plugin-chart-ag-grid/src/ag-grid/ContextMenu/MenuItems/RetainEmlMenuItem.tsx @@ -41,6 +41,7 @@ export default function RetainEmlMenuItem(props: RetainEmlMenuItemProps) { return `${year}-${month}-${day}`; }); } catch (error) { + // eslint-disable-next-line no-console console.error(`Error parsing dates, ignoring date columns: ${error}`); allDates = []; } @@ -57,6 +58,8 @@ export default function RetainEmlMenuItem(props: RetainEmlMenuItemProps) { window.open(json.result, '_blank'); }) .catch(error => { + // eslint-disable-next-line no-console + console.error(`Error retaining: ${error}`); dispatch( addDangerToast( 'Retention failed. The records you attempted to retain were not retained.', From 3f8a5b3d233e849b5b3676247b325f470a9a179c Mon Sep 17 00:00:00 2001 From: cccs-RyanK Date: Fri, 26 Jul 2024 10:22:00 -0400 Subject: [PATCH 3/3] actually add limit to retention query --- superset/alfred/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/superset/alfred/utils.py b/superset/alfred/utils.py index fb9f938aee267..02ba88469ee2a 100644 --- a/superset/alfred/utils.py +++ b/superset/alfred/utils.py @@ -241,6 +241,7 @@ def retain_eml_to_alfred(ids, alfred_env, access_token, dates=None): sql += " OR " sql += f"(time > TIMESTAMP '{datetimes[i].strftime('%Y-%m-%d')}' AND time < TIMESTAMP '{(datetimes[i] + timedelta(days=1)).strftime('%Y-%m-%d')}')" sql += ")" + sql += f" LIMIT {limit};" logger.info(f"Querying EML Data from trino at {trino_host}...") cur = conn.cursor() logger.info(f"Created Connection {cur.query_id}")