This commit is contained in:
2025-08-26 16:28:05 +03:00
parent 7fd2a6e55f
commit d4c3f51348
21 changed files with 93 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
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
) { }
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 getStats() {
return this.prisma.stats.findUnique({ where: { id: 1 } });
}
}