package com.beantimer.controller;


import com.beantimer.model.GanttMetric;
import com.beantimer.service.MetricService;
import ee.aktors.beantimer.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Controller
@RequestMapping("gantt")
public class GanttController {

    private final MetricService metricService;

    @Autowired
    public GanttController(MetricService metricService) {
        this.metricService = metricService;
    }

    @GetMapping()
    public ModelAndView showCities(@RequestParam(value="username",required = false) String username) {
//        List<GanttMetric> ganttMetrics = new ArrayList<>();
//        ganttMetrics.add(new GanttMetric("A", "aType", "scope", true, 130D, 100L, new Date().getTime(), null));
//        ganttMetrics.add(new GanttMetric("b", "bType", "scope", false, 140D, 170L, new Date().getTime() + 110, "A"));

        List<GanttMetric> ganttMetrics = metricService.getGanttMetrics("viktor_reinok");

        int limit = 10;
        if (ganttMetrics.size() > limit) {
            ganttMetrics = ganttMetrics.subList(0, limit);
        }
        String json = JsonUtil.transformToJsonArray(ganttMetrics);

        Map<String, Object> params = new HashMap<>();
        params.put("metrics", json);

        return new ModelAndView("gantt", params);
    }


}

@@ -954,305 +954,8 @@
 ) %7B%0A
-//        List%3CGanttMetric%3E ganttMetrics = new ArrayList%3C%3E();%0A//        ganttMetrics.add(new GanttMetric(%22A%22, %22aType%22, %22scope%22, true, 130D, 100L, new Date().getTime(), null));%0A//        ganttMetrics.add(new GanttMetric(%22b%22, %22bType%22, %22scope%22, false, 140D, 170L, new Date().getTime() + 110, %22A%22));%0A%0A
     
@@ -1064,9 +1064,11 @@
 t = 
-1
+200
 0;%0A 

Increase cap for controller