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