implemented fetching of previous month/year
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -4,8 +4,7 @@ package de.srsoftware.cal.db;
|
||||
import static de.srsoftware.tools.Optionals.*;
|
||||
import static de.srsoftware.tools.Result.transform;
|
||||
import static de.srsoftware.tools.Strings.camelCase;
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Condition.moreThan;
|
||||
import static de.srsoftware.tools.jdbc.Condition.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.MARK;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
@@ -221,15 +220,17 @@ public class MariaDB implements Database {
|
||||
@Override
|
||||
public List<Appointment> list(LocalDateTime from, LocalDateTime till) throws SQLException {
|
||||
var list = new ArrayList<Appointment>();
|
||||
var results = Query //
|
||||
.select("appointments.*", "GROUP_CONCAT(keyword) AS tags")
|
||||
.from(APPOINTMENTS)
|
||||
.leftJoin(AID, "appointment_tags", AID)
|
||||
.leftJoin("tid", "tags", "tid")
|
||||
.groupBy(AID)
|
||||
.sort("start")
|
||||
.where("start", moreThan(from))
|
||||
.exec(connection);
|
||||
var query = Query //
|
||||
.select("appointments.*", "GROUP_CONCAT(keyword) AS tags")
|
||||
.from(APPOINTMENTS)
|
||||
.leftJoin(AID, "appointment_tags", AID)
|
||||
.leftJoin("tid", "tags", "tid")
|
||||
.groupBy(AID)
|
||||
.sort("start DESC");
|
||||
nullable(from).ifPresent(start -> query.where("start", moreThan(start)));
|
||||
nullable(till).ifPresent(end -> query.where("end",lessThan(end)));
|
||||
|
||||
var results = query.exec(connection);
|
||||
while (results.next()) createAppointmentOf(results).optional().ifPresent(list::add);
|
||||
results.close();
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user