fix: remove invalid distinct option from Prisma findMany
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
Prisma v5.22 findMany does not support distinct — handled in JS instead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
098b8055f5
commit
3f2ba8ba93
@ -13,16 +13,21 @@ export class GrowthService {
|
||||
where: { userId },
|
||||
orderBy: { date: 'desc' },
|
||||
select: { date: true },
|
||||
distinct: ['date'],
|
||||
take: 365,
|
||||
});
|
||||
|
||||
if (activities.length === 0) return { currentStreak: 0, longestStreak: 0 };
|
||||
|
||||
const dates = activities.map(a => new Date(a.date).toISOString().slice(0, 10));
|
||||
let currentStreak = 1;
|
||||
let longestStreak = 1;
|
||||
let streak = 1;
|
||||
// Dedupe by date
|
||||
const seen = new Set<string>();
|
||||
const dates: string[] = [];
|
||||
for (const a of activities) {
|
||||
const d = new Date(a.date).toISOString().slice(0, 10);
|
||||
if (!seen.has(d)) { seen.add(d); dates.push(d); }
|
||||
}
|
||||
let currentStreak = dates.length > 0 ? 1 : 0;
|
||||
let longestStreak = currentStreak;
|
||||
let streak = currentStreak;
|
||||
|
||||
for (let i = 1; i < dates.length; i++) {
|
||||
const prev = new Date(dates[i - 1]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user