diff --git a/pom.xml b/pom.xml index 49cf277..aa9bb3c 100644 --- a/pom.xml +++ b/pom.xml @@ -31,11 +31,6 @@ - - com.google.visualization - visualization-datasource - 1.1.1 - de.flapdoodle.embed de.flapdoodle.embed.mongo diff --git a/web/pom.xml b/web/pom.xml index 9a0cbbf..1fc1e89 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -67,11 +67,6 @@ true - - com.google.visualization - visualization-datasource - - de.flapdoodle.embed de.flapdoodle.embed.mongo diff --git a/web/src/main/java/com/austenconstable/web/trend/TrendController.java b/web/src/main/java/com/austenconstable/web/trend/TrendController.java index ef08ffa..960d51e 100644 --- a/web/src/main/java/com/austenconstable/web/trend/TrendController.java +++ b/web/src/main/java/com/austenconstable/web/trend/TrendController.java @@ -12,21 +12,16 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; -import com.google.visualization.datasource.base.TypeMismatchException; -import com.google.visualization.datasource.datatable.ColumnDescription; -import com.google.visualization.datasource.datatable.DataTable; -import com.google.visualization.datasource.datatable.TableCell; -import com.google.visualization.datasource.datatable.TableRow; -import com.google.visualization.datasource.datatable.value.DateValue; -import com.google.visualization.datasource.datatable.value.ValueType; -import com.google.visualization.datasource.render.JsonRenderer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.mobile.device.Device; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import java.math.BigDecimal; import java.math.RoundingMode; @@ -35,8 +30,6 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.format.TextStyle; -import java.time.temporal.TemporalField; import java.time.temporal.WeekFields; import java.util.*; @@ -69,81 +62,8 @@ public static double round(double value, int places) { return bd.doubleValue(); } - @Deprecated - @RequestMapping("/trend/monthly/{team}") - @ResponseBody - public String rollingMonthlyTrend(Model model, @PathVariable String team) { - - DataTable data = new DataTable(); - - data.addColumn(new ColumnDescription("month", ValueType.DATE, "Month")); - data.addColumn(new ColumnDescription("happiness", ValueType.NUMBER, "Happiness")); - data.addColumn(new ColumnDescription("responses", ValueType.NUMBER, "Responses")); - - try { - ArrayList rows = new ArrayList<>(); - - ArrayList trends = trendService.getMonthlyTrendData(team); - - for (HappinessTrend trend:trends) { - TableRow tr = new TableRow(); - tr.addCell(new TableCell(new DateValue(trend.getTrendDate().getYear(), trend.getTrendDate().getMonth().getValue() - 1, 1) - , trend.getTrendDate().getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH))); - tr.addCell(trend.getAvgHappinessRating()); - tr.addCell(trend.getResponseCount()); - rows.add(tr); - } - - data.addRows(rows); - - } catch (TypeMismatchException e) { - System.out.print(e); - } - - return JsonRenderer.renderDataTable(data, true, true, false).toString(); - - } - - @Deprecated - @RequestMapping("/trend/weekly/{team}") - @ResponseBody - public String rollingWeeklyTrend(Model model, @PathVariable String team) { - - DataTable data = new DataTable(); - - data.addColumn(new ColumnDescription("week", ValueType.DATE, "Week")); - data.addColumn(new ColumnDescription("happiness", ValueType.NUMBER, "Happiness")); - data.addColumn(new ColumnDescription("responses", ValueType.NUMBER, "Responses")); - - try { - ArrayList rows = new ArrayList<>(); - - ArrayList trends = trendService.getWeeklyTrendData(team); - - TemporalField woy = WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear(); - - for (HappinessTrend trend:trends) { - TableRow tr = new TableRow(); - tr.addCell(new TableCell(new DateValue(trend.getTrendDate().getYear(), trend.getTrendDate().getMonth().getValue() - 1, trend.getTrendDate().getDayOfMonth()) - , "Week " + trend.getTrendDate().get(woy) + ", " + trend.getTrendDate().getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH) - + " " + trend.getTrendDate().getYear())); - tr.addCell(trend.getAvgHappinessRating()); - tr.addCell(trend.getResponseCount()); - rows.add(tr); - } - - data.addRows(rows); - - } catch (TypeMismatchException e) { - System.out.print(e); - } - - return JsonRenderer.renderDataTable(data, true, true, false).toString(); - - } - @GetMapping("/") - public String index(Device device) throws Exception { + public String index(Device device) { if(device.isMobile() || device.isTablet()){ return "thankyou"; @@ -153,13 +73,13 @@ public String index(Device device) throws Exception { } @GetMapping("/chart") - public String chart() throws Exception { + public String chart() { return "trendgraph"; } @GetMapping("/thankyou") - public String thankyou(Device device, @RequestParam(name="team", required = true) String teamId, - @RequestParam(name="rating", required = false) String rating, Model model) throws Exception { + public String thankyou(Device device, @RequestParam(name="team") String teamId, + @RequestParam(name="rating", required = false) String rating, Model model) { HierarchyEntity team = hierarchyClient.findEntityBySlug(teamId); @@ -192,7 +112,7 @@ private LineDataset createTrendDataSet(String dataSetName, HashMap(Arrays.asList(new Integer[]{5, 5}))); + dataset.setBorderDash(new ArrayList(Arrays.asList(5, 5))); } dataset.setYAxisID("y-axis-1"); return dataset; @@ -210,7 +130,7 @@ private LineDataset createCountDataSet(String dataSetName, HashMap(Arrays.asList(new Integer[]{5, 5}))); + dataset.setBorderDash(new ArrayList(Arrays.asList(5, 5))); } dataset.setYAxisID("y-axis-2"); return dataset;