Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(posts): return only non deleted posts and fix openAPI documentati…
Browse files Browse the repository at this point in the history
…on (#7)
  • Loading branch information
buehler authored Mar 14, 2023
1 parent 1f4258f commit dc24faf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/data/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class PostsService {
} else if (olderThan) {
idQuery = LessThan(olderThan);
}


const [posts, count] = await this.aggregatedPosts.findAndCount({
skip: offset,
Expand All @@ -56,7 +55,8 @@ export class PostsService {
where: {
parentId: IsNull(),
id: idQuery,
...(creator ? {creator} : {})
deleted: false,
...(creator ? { creator } : {}),
},
});
return { posts, count };
Expand Down Expand Up @@ -139,7 +139,7 @@ export class PostsService {
where: { id },
});
const replies = await this.aggregatedPosts.find({
where: { parentId: id },
where: { parentId: id, deleted: false },
order: { id: 'desc' },
});

Expand Down
7 changes: 4 additions & 3 deletions src/rest/posts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class PostsController {
name: 'creator',
required: false,
description:
'The ID of a creator. Only posts of this should be returned. If omitted, all posts are returned.',
'The ID of a creator. Only posts of the given creator should be returned. If omitted, all posts are returned.',
examples: {
'all posts': {
value: undefined,
Expand All @@ -152,7 +152,7 @@ export class PostsController {
type: 'array',
items: {
uniqueItems: true,
oneOf: [postSchema, replySchema, deletedSchema],
...postSchema,
},
},
count: {
Expand Down Expand Up @@ -258,7 +258,8 @@ export class PostsController {
type: 'array',
uniqueItems: true,
items: {
oneOf: [replySchema, deletedSchema],
uniqueItems: true,
...replySchema,
},
},
})
Expand Down

0 comments on commit dc24faf

Please sign in to comment.