working on project list: introducing task list
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package de.srsoftware.umbrella.time;
|
||||
|
||||
import static de.srsoftware.tools.jdbc.Condition.in;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.tools.jdbc.Query.select;
|
||||
import static de.srsoftware.umbrella.core.Constants.ID;
|
||||
import static de.srsoftware.umbrella.time.Constants.*;
|
||||
@@ -25,7 +26,7 @@ public class SqliteDb implements TimeDb {
|
||||
@Override
|
||||
public Collection<Time> listTimes(Collection<Long> taskIds) throws UmbrellaException {
|
||||
try {
|
||||
var rs = select("*").from(TABLE_TASK_TIMES).where(TASK_ID,in(taskIds.toArray())).exec(db);
|
||||
var rs = select(ALL).from(TABLE_TASK_TIMES).where(TASK_ID,in(taskIds.toArray())).exec(db);
|
||||
var mapFromTimesToTasks = new HashMap<Long,HashSet<Long>>();
|
||||
while (rs.next()){
|
||||
var timeId = rs.getLong(TIME_ID);
|
||||
@@ -33,7 +34,7 @@ public class SqliteDb implements TimeDb {
|
||||
mapFromTimesToTasks.computeIfAbsent(timeId, k -> new HashSet<>()).add(taskId);
|
||||
}
|
||||
rs.close();
|
||||
rs = select("*").from(TABLE_TIMES).where(ID,in(mapFromTimesToTasks.keySet().toArray())).exec(db);
|
||||
rs = select(ALL).from(TABLE_TIMES).where(ID,in(mapFromTimesToTasks.keySet().toArray())).exec(db);
|
||||
var times = new HashSet<Time>();
|
||||
while (rs.next()) {
|
||||
var time = Time.of(rs);
|
||||
|
||||
@@ -20,7 +20,6 @@ import de.srsoftware.umbrella.core.model.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TimeModule extends BaseHandler implements TimeService {
|
||||
|
||||
@@ -114,7 +113,7 @@ public class TimeModule extends BaseHandler implements TimeService {
|
||||
if (!companies.membership(companyId,user.id())) throw forbidden("You are mot a member of company {0}",company.name());
|
||||
if (!(json.has(PROJECT_ID) && json.get(PROJECT_ID) instanceof Number pid)) throw missingFieldException(PROJECT_ID);
|
||||
long projectId = pid.longValue();
|
||||
Map<Long,Task> tasksOfProject = tasks.listProjectTasks(projectId).stream().collect(Collectors.toMap(Task::id,t->t));
|
||||
Map<Long,Task> tasksOfProject = tasks.listProjectTasks(projectId);
|
||||
|
||||
List<Map<String, Object>> times = timeDb.listTimes(tasksOfProject.keySet())
|
||||
.stream().filter(not(Time::isClosed))
|
||||
|
||||
Reference in New Issue
Block a user