UNPKG

@wepublish/api

Version:
50 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StatsService = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs/common"); const client_1 = require("@prisma/client"); let StatsService = exports.StatsService = class StatsService { constructor(prisma) { this.prisma = prisma; } getAuthorsCount() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.prisma.author.count(); }); } getArticlesCount() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.prisma.article.count({ where: { publishedId: { not: null } } }); }); } getFirstArticleDate() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const earliestArticle = yield this.prisma.articleRevision.findFirst({ where: { publishedAt: { not: null } }, orderBy: { publishedAt: 'asc' }, select: { publishedAt: true } }); return (earliestArticle === null || earliestArticle === void 0 ? void 0 : earliestArticle.publishedAt) || null; }); } }; exports.StatsService = StatsService = tslib_1.__decorate([ (0, common_1.Injectable)(), tslib_1.__metadata("design:paramtypes", [client_1.PrismaClient]) ], StatsService); //# sourceMappingURL=stats.service.js.map