Fixing the error in today's task count
This commit is contained in:
@@ -69,6 +69,24 @@ export class ActivitiesService {
|
||||
): Promise<ActivitySummaryDto> {
|
||||
const { start, end } = dayBounds();
|
||||
const scope = assigneeWhere(actor);
|
||||
const [todayCount, overdueCount] = await Promise.all([
|
||||
this.prisma.activity.count({
|
||||
where: {
|
||||
organizationId,
|
||||
...scope,
|
||||
status: 'open',
|
||||
dueAt: { gte: start, lt: end },
|
||||
},
|
||||
}),
|
||||
this.prisma.activity.count({
|
||||
where: {
|
||||
organizationId,
|
||||
...scope,
|
||||
status: 'open',
|
||||
dueAt: { lt: start },
|
||||
},
|
||||
}),
|
||||
]);
|
||||
const [today, overdue, upcoming] = await Promise.all([
|
||||
this.prisma.activity.findMany({
|
||||
where: {
|
||||
@@ -109,8 +127,8 @@ export class ActivitiesService {
|
||||
today: today.map((row) => this.toDto(row)),
|
||||
overdue: overdue.map((row) => this.toDto(row)),
|
||||
upcoming: upcoming.map((row) => this.toDto(row)),
|
||||
todayCount: today.length,
|
||||
overdueCount: overdue.length,
|
||||
todayCount,
|
||||
overdueCount,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ async function refreshNotifs() {
|
||||
async function loadActivityBadge() {
|
||||
try {
|
||||
const { data } = await api.get<ActivitySummaryDto>('/activities/summary');
|
||||
activityBadge.value = data.todayCount + data.overdueCount;
|
||||
activityBadge.value = data.todayCount;
|
||||
} catch {
|
||||
activityBadge.value = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user