Skip to content

Commit af7f706

Browse files
committed
Refactor article retrieval logic by removing unused columns in queries and updating the ArticleTag join to include additional fields. Enhance ArticleEditorDrawer to display article data for better debugging during editing.
1 parent e86b79f commit af7f706

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

src/app/(dashboard-editor)/dashboard/articles/[uuid]/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const page: React.FC<Props> = async ({ params }) => {
2424
const [article] = await persistenceRepository.article.findRows({
2525
limit: 1,
2626
where: and(eq("id", _params.uuid), eq("author_id", sessionUserId)),
27-
columns: ["id", "title", "handle"],
2827
joins: [
2928
leftJoin<Article, User>({
3029
as: "author",
@@ -38,14 +37,13 @@ const page: React.FC<Props> = async ({ params }) => {
3837

3938
const aggregatedTags = await persistenceRepository.articleTag.findRows({
4039
where: inArray("article_id", [article.id]),
41-
columns: ["tag_id", "article_id"],
4240
joins: [
4341
leftJoin<ArticleTag, Tag>({
4442
as: "tag",
4543
joinTo: "tags",
4644
localField: "tag_id",
4745
foreignField: "id",
48-
columns: ["id", "name", "created_at"],
46+
columns: ["id", "name", "color", "icon", "description"],
4947
}),
5048
],
5149
});

src/backend/services/article.actions.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ export async function updateMyArticle(
231231
metadata: input.metadata,
232232
},
233233
});
234-
// a 1, t 1
235-
// a 1, t 2
236-
// a 1, t 3
237-
238-
// a-> (2,3,4)
239234

240235
if (input.tag_ids) {
241236
await persistenceRepository.articleTag.deleteRows({
@@ -443,13 +438,13 @@ export async function articleDetailByHandle(article_handle: string) {
443438
foreignField: "id",
444439
columns: ["id", "name", "username", "profile_photo"],
445440
}),
446-
manyToManyJoin<Article, Tag>({
447-
as: "tags",
448-
pivotTable: DatabaseTableName.article_tag,
449-
localField: "id",
450-
foreignField: "id",
451-
columns: ["id", "name", "icon", "color", "description"],
452-
}),
441+
// manyToManyJoin<Article, Tag>({
442+
// as: "tags",
443+
// pivotTable: DatabaseTableName.article_tag,
444+
// localField: "id",
445+
// foreignField: "id",
446+
// columns: ["id", "name", "icon", "color", "description"],
447+
// }),
453448
],
454449
limit: 1,
455450
});

src/components/Editor/ArticleEditorDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
109109
className="flex flex-col gap-2"
110110
>
111111
{/* {JSON.stringify(form.formState.errors)} */}
112-
112+
<pre>{JSON.stringify(article, null, 2)}</pre>
113113
<FormField
114114
control={form.control}
115115
name="handle"

0 commit comments

Comments
 (0)