package de.kopis.timeclicker.controllers;

import de.kopis.timeclicker.api.TimeclickerAPI;
import de.kopis.timeclicker.exceptions.NotAuthenticatedException;
import de.kopis.timeclicker.model.TimeEntry;
import de.kopis.timeclicker.model.TimeSumWithDate;
import de.kopis.timeclicker.utils.TimeSumUtility;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@Controller
@RequestMapping("/charts")
public class ChartController {
  public static final int LIMIT = 31 * 12;
  private final TimeclickerAPI api = new TimeclickerAPI();
  private final UserService userService = UserServiceFactory.getUserService();

  @GetMapping("/weekly")
  public String getWeeklyChart(Model model) throws NotAuthenticatedException {
    final User user = userService.getCurrentUser();

    final List<TimeEntry> allEntries = api.list(LIMIT, 0, user);
    final List<TimeSumWithDate> sortedPerWeek = new TimeSumUtility().calculateWeeklyTimeSum(allEntries);
    Collections.sort(sortedPerWeek, Comparator.comparing(TimeSumWithDate::getDate));
    model.addAttribute("weeklySums", sortedPerWeek);

    return "charts/weekly";
  }

  @GetMapping("/daily")
  public String getDailyChart(Model model) throws NotAuthenticatedException {
    final User user = userService.getCurrentUser();

    final List<TimeEntry> allEntries = api.list(LIMIT, 0, user);
    final List<TimeSumWithDate> sortedPerDay = new TimeSumUtility().calculateDailyTimeSum(allEntries);
    Collections.sort(sortedPerDay, Comparator.comparing(TimeSumWithDate::getDate));
    model.addAttribute("dailySums", sortedPerDay);

    return "charts/daily";
  }
}

package de.kopis.timeclicker.controllers;

import de.kopis.timeclicker.api.TimeclickerAPI;
import de.kopis.timeclicker.exceptions.NotAuthenticatedException;
import de.kopis.timeclicker.model.TimeEntry;
import de.kopis.timeclicker.model.TimeSumWithDate;
import de.kopis.timeclicker.utils.TimeSumUtility;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@Controller
@RequestMapping("/charts")
public class ChartController {
  private final TimeclickerAPI api = new TimeclickerAPI();
  private final UserService userService = UserServiceFactory.getUserService();

  @GetMapping("/weekly")
  public String getWeeklyChart(Model model,
                               @RequestParam(defaultValue = "31") int limit,
                               @RequestParam(defaultValue = "0") int page) throws NotAuthenticatedException {
    final User user = userService.getCurrentUser();

    final List<TimeEntry> allEntries = api.list(limit, page, user);
    final List<TimeSumWithDate> sortedPerWeek = new TimeSumUtility().calculateWeeklyTimeSum(allEntries);
    Collections.sort(sortedPerWeek, Comparator.comparing(TimeSumWithDate::getDate));
    model.addAttribute("weeklySums", sortedPerWeek);

    return "charts/weekly";
  }

  @GetMapping("/daily")
  public String getDailyChart(Model model,
                              @RequestParam(defaultValue = "31") int limit,
                              @RequestParam(defaultValue = "0") int page) throws NotAuthenticatedException {
    final User user = userService.getCurrentUser();

    final List<TimeEntry> allEntries = api.list(limit, page, user);
    final List<TimeSumWithDate> sortedPerDay = new TimeSumUtility().calculateDailyTimeSum(allEntries);
    Collections.sort(sortedPerDay, Comparator.comparing(TimeSumWithDate::getDate));
    model.addAttribute("dailySums", sortedPerDay);

    return "charts/daily";
  }
}

Add limit+page as RequestParam