This commit is contained in:
2025-08-27 21:24:13 +03:00
parent beb033bb6f
commit ef12ba29d1
10 changed files with 140 additions and 174 deletions

View File

@@ -3,7 +3,7 @@ import { PrismaClient } from 'generated/prisma';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}
}
async onModuleInit() {
await this.$connect();
}
}

View File

@@ -1,34 +1,33 @@
import { Injectable } from "@nestjs/common";
import { PrismaService } from "./prisma.service";
import { AppGetaway } from "src/app.getaway";
import { Injectable } from '@nestjs/common';
import { PrismaService } from './prisma.service';
import { AppGetaway } from 'src/app.getaway';
@Injectable()
export class StatsService {
constructor(
private prisma: PrismaService,
private socketService: AppGetaway
) { }
constructor(
private prisma: PrismaService,
private socketService: AppGetaway,
) {}
async incrementVisits() {
const stats = await this.prisma.stats.update({
where: { id: 1 },
data: { totalVisits: { increment: 1 } },
});
this.socketService.server.emit('statsUpdated', stats);
return stats;
}
async incrementVisits() {
const stats = await this.prisma.stats.update({
where: { id: 1 },
data: { totalVisits: { increment: 1 } },
});
this.socketService.server.emit('statsUpdated', stats);
return stats;
}
async incrementClicks() {
const stats = await this.prisma.stats.update({
where: { id: 1 },
data: { totalClicks: { increment: 1 } },
});
this.socketService.server.emit('statsUpdated', stats);
return stats;
}
async incrementClicks() {
const stats = await this.prisma.stats.update({
where: { id: 1 },
data: { totalClicks: { increment: 1 } },
});
this.socketService.server.emit('statsUpdated', stats);
return stats;
}
async getStats() {
return this.prisma.stats.findUnique({ where: { id: 1 } });
}
async getStats() {
return this.prisma.stats.findUnique({ where: { id: 1 } });
}
}