dashboard should only show finished articles
This commit is contained in:
parent
cf20c4c725
commit
bb8b532afc
@ -1,6 +1,6 @@
|
||||
/** @typedef {import("fastify").FastifyInstance} FastifyInstance */
|
||||
|
||||
import { and, desc, eq, getTableColumns, inArray, notInArray, sql } from "drizzle-orm";
|
||||
import { and, desc, eq, getTableColumns, inArray, notInArray, sql, not } from "drizzle-orm";
|
||||
import { db } from "../db/index.js";
|
||||
import { articles, articles as articlesTable, signups as signupsTable, sites, users } from "../db/schemas.js";
|
||||
import { authMiddleware, authMiddlewareFn } from "../modules/middleware.js";
|
||||
@ -40,7 +40,7 @@ export const dashboardRoutes = (fastify, _, done) => {
|
||||
.where(eq(signupsTable.site_id, site_id))
|
||||
.orderBy(desc(signupsTable.created_at)).limit(8);
|
||||
|
||||
const [{ totalArticles }] = await db.select({ totalArticles: sql`count(*)` }).from(articlesTable).where(eq(articlesTable.site_id, site_id));
|
||||
const [{ totalArticles }] = await db.select({ totalArticles: sql`count(*)` }).from(articlesTable).where(and(eq(articlesTable.site_id, site_id), eq(articlesTable.status, "done")));
|
||||
const [{ totalViews }] = await db.select({ totalViews: sql`COALESCE(sum(${articlesTable.views}), 0)` }).from(articlesTable).where(eq(articlesTable.site_id, site_id));
|
||||
const [{ totalEmails }] = await db.select({ totalEmails: sql`count(*)` }).from(signupsTable).where(eq(signupsTable.site_id, site_id));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user