fix(reporting-service): use named unique constraint for realtimeStats queries
Prisma requires using the named unique constraint (uk_realtime_stats_date) in where clauses for findUnique and upsert operations. This fixes the PrismaClientValidationError that was occurring when processing planting order events. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d400290652
commit
ce1d342269
|
|
@ -16,7 +16,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
const statsDate = this.normalizeDate(date);
|
||||
|
||||
const existing = await this.prisma.realtimeStats.findUnique({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
|
|
@ -34,7 +34,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
const statsDate = this.normalizeDate(date);
|
||||
|
||||
const found = await this.prisma.realtimeStats.findUnique({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
});
|
||||
|
||||
return found ? this.toDomain(found) : null;
|
||||
|
|
@ -55,7 +55,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
);
|
||||
|
||||
const result = await this.prisma.realtimeStats.upsert({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
create: {
|
||||
statsDate,
|
||||
dailyPlantingCount: safeTreeCount,
|
||||
|
|
@ -76,7 +76,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
const statsDate = this.normalizeDate(date);
|
||||
|
||||
const result = await this.prisma.realtimeStats.upsert({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
create: {
|
||||
statsDate,
|
||||
dailyOrderCount: 1,
|
||||
|
|
@ -94,7 +94,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
this.logger.debug(`Incrementing new user: date=${statsDate.toISOString()}`);
|
||||
|
||||
const result = await this.prisma.realtimeStats.upsert({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
create: {
|
||||
statsDate,
|
||||
dailyNewUserCount: 1,
|
||||
|
|
@ -114,7 +114,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
);
|
||||
|
||||
const result = await this.prisma.realtimeStats.upsert({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
create: {
|
||||
statsDate,
|
||||
dailyProvinceAuthCount: 1,
|
||||
|
|
@ -132,7 +132,7 @@ export class RealtimeStatsRepository implements IRealtimeStatsRepository {
|
|||
this.logger.debug(`Incrementing city auth: date=${statsDate.toISOString()}`);
|
||||
|
||||
const result = await this.prisma.realtimeStats.upsert({
|
||||
where: { statsDate },
|
||||
where: { uk_realtime_stats_date: { statsDate } },
|
||||
create: {
|
||||
statsDate,
|
||||
dailyCityAuthCount: 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue