-
Notifications
You must be signed in to change notification settings - Fork 0
Filter on reported comments #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: copilot_only-issues-20260113-qodo-grep-copilot_base_filter_on_reported_comments_pr98
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ export type Comment = { | |
| count?: { | ||
| replies?: number; | ||
| likes?: number; | ||
| reports?: number; | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,12 @@ const countFields = [ | |
| 'likes' | ||
| ]; | ||
|
|
||
| const countFieldsAdmin = [ | ||
| 'replies', | ||
| 'likes', | ||
| 'reports' | ||
| ]; | ||
|
|
||
| const commentMapper = (model, frame) => { | ||
| const jsonModel = model.toJSON ? model.toJSON(frame.options) : model; | ||
|
|
||
|
|
@@ -87,7 +93,7 @@ const commentMapper = (model, frame) => { | |
| } | ||
|
|
||
| if (jsonModel.count) { | ||
| response.count = _.pick(jsonModel.count, countFields); | ||
| response.count = _.pick(jsonModel.count, isPublicRequest ? countFieldsAdmin : countFields); | ||
|
||
| } | ||
|
|
||
| if (isPublicRequest) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,6 +181,8 @@ class CommentsService { | |
| * @property {boolean} includeNested - If true, include replies in flat list; if false, only top-level comments | ||
| * @property {string[]} [withRelated] - Relations to include (e.g. ['member', 'post']) | ||
| * @property {string} [filter] - NQL filter string | ||
| * @property {Function} [mongoTransformer] - Function to transform parsed NQL filter | ||
| * @property {{op: string, value: number}} [reportCount] - Filter by report count (op: '=', '>', '>=', '<', '<=', '!=') | ||
| * @property {string} order - Order string (e.g. 'created_at desc') | ||
| * @property {number} [page] - Page number | ||
| * @property {number} [limit] - Results per page | ||
|
|
@@ -195,10 +197,12 @@ class CommentsService { | |
| * | ||
| * @param {AdminBrowseAllOptions} options | ||
| */ | ||
| async getAdminAllComments({includeNested, filter, order, page, limit}) { | ||
| async getAdminAllComments({includeNested, filter, mongoTransformer, reportCount, order, page, limit}) { | ||
| return await this.models.Comment.findPage({ | ||
| withRelated: ['member', 'post'], | ||
| withRelated: ['member', 'post', 'count.replies', 'count.likes'], | ||
|
||
| filter, | ||
| mongoTransformer, | ||
| reportCount, | ||
| order, | ||
| page, | ||
| limit, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filter logic is inverted. When the user selects 'reported: Yes' (value='true'), the code filters for
count.reports:0which means zero reports (not reported). Similarly, 'reported: No' (value='false') filters forcount.reports:>0(has reports). The conditions should be swapped: 'true' should map tocount.reports:>0and 'false' should map tocount.reports:0.