Skip to content

Commit e02bbd7

Browse files
committed
refactor: update comment resource type and improve session ID retrieval in dashboard actions
1 parent e494adc commit e02bbd7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/app/dashboard/_components/MatrixReport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Card, CardContent } from "@/components/ui/card";
55
import { useTranslation } from "@/i18n/use-translation";
66
import { useQuery } from "@tanstack/react-query";
77
import { LoaderIcon } from "lucide-react";
8-
import React from "react";
8+
import React, { useEffect } from "react";
99

1010
const MatrixReport = () => {
1111
const { _t } = useTranslation();

src/backend/services/dashboard.action.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

3-
import * as sessionActions from "@/backend/services/session.actions";
43
import { pgClient } from "@/backend/persistence/clients";
4+
import { authID } from "@/backend/services/session.actions";
55

66
const sql = String.raw;
77

@@ -12,15 +12,15 @@ SELECT (SELECT Count(*)
1212
AS total_articles,
1313
(SELECT Count(*)
1414
FROM comments
15-
WHERE comments.commentable_type = 'ARTICLE'
16-
AND comments.commentable_id IN (SELECT id
15+
WHERE comments.resource_type = 'ARTICLE'
16+
AND comments.resource_id IN (SELECT id
1717
FROM articles
1818
WHERE articles.author_id = $1))
1919
AS total_comments
2020
`;
2121

2222
export async function myArticleMatrix() {
23-
const sessionUserId = await sessionActions.authID();
23+
const sessionUserId = await authID();
2424

2525
const totalPostsQuery = await pgClient?.executeSQL<any>(query, [
2626
sessionUserId!,

0 commit comments

Comments
 (0)