From df2f87044aa559cbb362993e618bdf9c287fe15b Mon Sep 17 00:00:00 2001 From: Kparikh9 Date: Tue, 5 Oct 2021 23:20:37 -0400 Subject: [PATCH] Moved else-if branch for timeline to meet user id case and reduce code --- greenstand/Map.js | 17 +++++++++++++++++ greenstand/sqls/SQLCase1Timeline.js | 3 +++ greenstand/sqls/SQLCase2Timeline.js | 3 +++ greenstand/sqls/SQLCase3Timeline.js | 3 +++ 4 files changed, 26 insertions(+) diff --git a/greenstand/Map.js b/greenstand/Map.js index d59183d608..577a361cee 100644 --- a/greenstand/Map.js +++ b/greenstand/Map.js @@ -39,6 +39,23 @@ class Map{ }else if(this.capture_id){ this.sql = new SQLCase2(); this.sql.addUUIDFilter(this.capture_id); + }else if(this.timeline){ + if(this.zoomLevel > 15){ + this.sql = new SQLCase2Timeline(); + this.sql.addTimeline(this.timeline); + this.sql.setBounds(this.bounds); + } else if ([12, 13, 14, 15].includes(this.zoomLevel) ) { + this.sql = new SQLCase3Timeline(); + this.sql.setZoomLevel(this.zoomLevel); + this.sql.setBounds(this.bounds); + this.sql.addTimeline(this.timeline); + }else{ + this.sql = new SQLCase1Timeline(); + this.sql.addTimeline(this.timeline); + this.sql.setBounds(this.bounds); + this.sql.setZoomLevel(this.zoomLevel); + } + this.sql.addFilterByUserId(this.userid) }else if(this.userid){ /* * User map mode diff --git a/greenstand/sqls/SQLCase1Timeline.js b/greenstand/sqls/SQLCase1Timeline.js index 157ef044ec..3e65ad2d9a 100644 --- a/greenstand/sqls/SQLCase1Timeline.js +++ b/greenstand/sqls/SQLCase1Timeline.js @@ -36,6 +36,9 @@ class SQLCase1Timeline extends SQLCase1{ AND trees.time_created > '${begin}' AND trees.time_created < '${end}' `; } + if(this.userId){ + result += "AND trees.planter_id = " + this.userId + " \n"; + } return result; } } diff --git a/greenstand/sqls/SQLCase2Timeline.js b/greenstand/sqls/SQLCase2Timeline.js index c760c476a0..e82ecdebe2 100644 --- a/greenstand/sqls/SQLCase2Timeline.js +++ b/greenstand/sqls/SQLCase2Timeline.js @@ -15,6 +15,9 @@ class SQLCase2Timeline extends SQLCase2{ AND trees.time_created > '${begin}' AND trees.time_created < '${end}' `; } + if(this.userId){ + result += "AND trees.planter_id = " + this.userId + " \n"; + } return result; } diff --git a/greenstand/sqls/SQLCase3Timeline.js b/greenstand/sqls/SQLCase3Timeline.js index fb3161bb75..37a2efd6f5 100644 --- a/greenstand/sqls/SQLCase3Timeline.js +++ b/greenstand/sqls/SQLCase3Timeline.js @@ -39,6 +39,9 @@ class SQLCase3Timeline extends SQLCase3{ AND trees.time_created > '${begin}' AND trees.time_created < '${end}' `; } + if(this.userId){ + result += "AND trees.planter_id = " + this.userId + " \n"; + } return result; }