Skip to content
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

How to filter only comments that are not in an thread #201

Closed
OliveiraCleidson opened this issue Apr 6, 2023 · 4 comments
Closed

How to filter only comments that are not in an thread #201

OliveiraCleidson opened this issue Apr 6, 2023 · 4 comments
Labels
bug Something isn't working solved Issue has been solved v4 Strapi v4

Comments

@OliveiraCleidson
Copy link

How to filter only comments that are not in a thread

I'm working on one feature that gets comments with pagination. I won't get comments sorted by created date and only comments that are root comments, then I'm using the REST API in flat mode.

Bugs (?)

But when I try to filter using threadOf the server returns 5xx.
image

When I use threadOf with id, the threadOf field does not return the correct content inner threadOf, but the filter works.
image

When I try to use threadFirstItemId
image

image

My dependencies:

{
"dependencies": {
      "@strapi-community/strapi-provider-upload-google-cloud-storage": "^4.3.6",
      "@strapi/plugin-documentation": "^4.4.1",
      "@strapi/plugin-i18n": "4.6.1",
      "@strapi/plugin-sentry": "^4.5.0",
      "@strapi/plugin-users-permissions": "4.6.1",
      "@strapi/strapi": "4.6.1",
      "elastic-apm-node": "^3.40.1",
      "pg": "8.6.0",
      "sharp": "^0.31.2",
      "strapi-plugin-comments": "^2.2.4",
      "strapi-plugin-import-export-entries": "^1.18.0"
  }
}

My plugin.ts

comments: {
    enabled: true,
    config: {
      // ##Documentation https://market.strapi.io/plugins/strapi-plugin-comments
    },
}

My node version Is 16.17.0

@cyp3rius
Copy link
Collaborator

cyp3rius commented Apr 7, 2023

Hello @OliveiraCleidson ,

So step by step :)

  1. filters[threadOf][$null]=true

It causes 500 because of following error and that's purely Strapi error. I assume the case here is with relation property.

{
  threadOf: { '$null': 'true' },
  '$or': [ { removed: [Object] }, { removed: false } ],
  related: 'api::page.page:1'
}
[2023-04-07 15:47:25.215] error: Only $and, $or and $not can only be used as root level operators. Found $null.
Error: Only $and, $or and $not can only be used as root level operators. Found $null.
    at processWhere (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:140:13)
    at processNested (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:116:12)
    at processWhere (/Users/mziarko/Projects/open-source/strapi-v4/node_modules/@strapi/database/lib/query/helpers/where.js:161:25)
  1. filters[threadOf][id][$null]=true

This returned value is our error in reality as we're getting 1:1 from query. I will fix that in next release, but such query is correct.

  1. The threadFirstItemId is not DB field but calculated property. You can't query by it.

@cyp3rius cyp3rius added bug Something isn't working question Further information is requested v4 Strapi v4 investigation Issue under investigation labels Apr 7, 2023
@OliveiraCleidson
Copy link
Author

Exists a method that gets only root comments in a request?

I can work on this fix.

@cyp3rius
Copy link
Collaborator

cyp3rius commented Apr 12, 2023

Nope, there is no such dedicated method - ideally it should be done by the way you described.

If you can fix point 2. we would be grateful :) Should be fairly quick one liner at the end of service method.

@cyp3rius
Copy link
Collaborator

Released as part of v2.2.10

@cyp3rius cyp3rius added solved Issue has been solved and removed question Further information is requested investigation Issue under investigation labels Apr 26, 2023
github-actions bot pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Oct 4, 2023
# [1.1.0](v1.0.2...v1.1.0) (2023-10-04)

### Bug Fixes

* add types to Avatar component ([f12ea9c](f12ea9c))
* author blocked props ([d9d0777](d9d0777))
* author population ([VirtusLab-Open-Source#177](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/177)) ([5ba0d85](5ba0d85))
* change error 403 test ([99ec162](99ec162))
* custom field on existing entity ([VirtusLab-Open-Source#178](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/178)) ([5e6cc63](5e6cc63))
* fixed UserAvatar typing ([dd179c7](dd179c7))
* fixes after merge ([3b9eee2](3b9eee2))
* issue [VirtusLab-Open-Source#199](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/199) - undeclared codemirror dependency causes build crash ([ccc1f98](ccc1f98))
* issue [VirtusLab-Open-Source#201](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/201) fix the filtering by thread ([bdc292a](bdc292a))
* issue [VirtusLab-Open-Source#220](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/220), issue [VirtusLab-Open-Source#221](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/221) ([VirtusLab-Open-Source#222](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/222)) ([03d504a](03d504a))
* load only existing translations ([e0cea8d](e0cea8d))
* package.json outdated ([1ef26e5](1ef26e5))
* peer dependency ([50bd59c](50bd59c))
* stick to older match-sorter dependency following strapi ([70dd408](70dd408))
* strapi 4.13 packages alignment ([VirtusLab-Open-Source#229](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/229)) ([3432cd2](3432cd2))
* strapi v4.7.1 compatibility fix because of dependencies ([563f86c](563f86c))
* unused import removed ([ac7d47f](ac7d47f))

### Features

* **api:** issue [VirtusLab-Open-Source#209](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/209) - find all by author ([e47684a](e47684a))
* author entity props blocking ([VirtusLab-Open-Source#186](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/186)) ([6134f1e](6134f1e))
* basic filters options added to Discover and Reports ([074d23a](074d23a))
* comments custom field [CU-2tn2923] ([VirtusLab-Open-Source#157](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/157)) ([aaac8a0](aaac8a0)), closes [VirtusLab-Open-Source#158](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/158)
* create reports page [CU-20rfmkv] ([VirtusLab-Open-Source#153](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/153)) ([15b9b57](15b9b57))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a284d59](a284d59))
* typescripted client service and controllers ([eddd4b3](eddd4b3))
gabrielsclimaco pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Dec 20, 2023
# [1.1.0](v1.0.2...v1.1.0) (2023-10-04)

### Bug Fixes

* add types to Avatar component ([f12ea9c](f12ea9c))
* author blocked props ([d9d0777](d9d0777))
* author population ([VirtusLab-Open-Source#177](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/177)) ([5ba0d85](5ba0d85))
* change error 403 test ([99ec162](99ec162))
* custom field on existing entity ([VirtusLab-Open-Source#178](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/178)) ([5e6cc63](5e6cc63))
* fixed UserAvatar typing ([dd179c7](dd179c7))
* fixes after merge ([3b9eee2](3b9eee2))
* issue [VirtusLab-Open-Source#199](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/199) - undeclared codemirror dependency causes build crash ([ccc1f98](ccc1f98))
* issue [VirtusLab-Open-Source#201](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/201) fix the filtering by thread ([bdc292a](bdc292a))
* issue [VirtusLab-Open-Source#220](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/220), issue [VirtusLab-Open-Source#221](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/221) ([VirtusLab-Open-Source#222](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/222)) ([03d504a](03d504a))
* load only existing translations ([e0cea8d](e0cea8d))
* package.json outdated ([1ef26e5](1ef26e5))
* peer dependency ([50bd59c](50bd59c))
* stick to older match-sorter dependency following strapi ([70dd408](70dd408))
* strapi 4.13 packages alignment ([VirtusLab-Open-Source#229](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/229)) ([3432cd2](3432cd2))
* strapi v4.7.1 compatibility fix because of dependencies ([563f86c](563f86c))
* unused import removed ([ac7d47f](ac7d47f))

### Features

* **api:** issue [VirtusLab-Open-Source#209](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/209) - find all by author ([e47684a](e47684a))
* author entity props blocking ([VirtusLab-Open-Source#186](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/186)) ([6134f1e](6134f1e))
* basic filters options added to Discover and Reports ([074d23a](074d23a))
* comments custom field [CU-2tn2923] ([VirtusLab-Open-Source#157](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/157)) ([aaac8a0](aaac8a0)), closes [VirtusLab-Open-Source#158](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/158)
* create reports page [CU-20rfmkv] ([VirtusLab-Open-Source#153](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/153)) ([15b9b57](15b9b57))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a284d59](a284d59))
* typescripted client service and controllers ([eddd4b3](eddd4b3))
gabrielsclimaco pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Dec 20, 2023
* add types to Avatar component ([f12ea9c](f12ea9c))
* author blocked props ([d9d0777](d9d0777))
* author population ([VirtusLab-Open-Source#177](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/177)) ([5ba0d85](5ba0d85))
* change error 403 test ([99ec162](99ec162))
* custom field on existing entity ([VirtusLab-Open-Source#178](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/178)) ([5e6cc63](5e6cc63))
* fixed UserAvatar typing ([dd179c7](dd179c7))
* fixes after merge ([3b9eee2](3b9eee2))
* issue [VirtusLab-Open-Source#199](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/199) - undeclared codemirror dependency causes build crash ([ccc1f98](ccc1f98))
* issue [VirtusLab-Open-Source#201](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/201) fix the filtering by thread ([bdc292a](bdc292a))
* issue [VirtusLab-Open-Source#220](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/220), issue [VirtusLab-Open-Source#221](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/221) ([VirtusLab-Open-Source#222](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/222)) ([03d504a](03d504a))
* load only existing translations ([e0cea8d](e0cea8d))
* package.json outdated ([1ef26e5](1ef26e5))
* peer dependency ([50bd59c](50bd59c))
* stick to older match-sorter dependency following strapi ([70dd408](70dd408))
* strapi 4.13 packages alignment ([VirtusLab-Open-Source#229](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/229)) ([3432cd2](3432cd2))
* strapi v4.7.1 compatibility fix because of dependencies ([563f86c](563f86c))
* unused import removed ([ac7d47f](ac7d47f))

* **api:** issue [VirtusLab-Open-Source#209](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/209) - find all by author ([e47684a](e47684a))
* author entity props blocking ([VirtusLab-Open-Source#186](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/186)) ([6134f1e](6134f1e))
* basic filters options added to Discover and Reports ([074d23a](074d23a))
* comments custom field [CU-2tn2923] ([VirtusLab-Open-Source#157](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/157)) ([aaac8a0](aaac8a0)), closes [VirtusLab-Open-Source#158](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/158)
* create reports page [CU-20rfmkv] ([VirtusLab-Open-Source#153](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/153)) ([15b9b57](15b9b57))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a284d59](a284d59))
* typescripted client service and controllers ([eddd4b3](eddd4b3))
gabrielsclimaco pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Dec 20, 2023
* add types to Avatar component ([f12ea9c](f12ea9c))
* author blocked props ([d9d0777](d9d0777))
* author population ([VirtusLab-Open-Source#177](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/177)) ([5ba0d85](5ba0d85))
* change error 403 test ([99ec162](99ec162))
* custom field on existing entity ([VirtusLab-Open-Source#178](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/178)) ([5e6cc63](5e6cc63))
* fixed UserAvatar typing ([dd179c7](dd179c7))
* fixes after merge ([3b9eee2](3b9eee2))
* issue [VirtusLab-Open-Source#199](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/199) - undeclared codemirror dependency causes build crash ([ccc1f98](ccc1f98))
* issue [VirtusLab-Open-Source#201](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/201) fix the filtering by thread ([bdc292a](bdc292a))
* issue [VirtusLab-Open-Source#220](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/220), issue [VirtusLab-Open-Source#221](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/221) ([VirtusLab-Open-Source#222](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/222)) ([03d504a](03d504a))
* load only existing translations ([e0cea8d](e0cea8d))
* package.json outdated ([1ef26e5](1ef26e5))
* peer dependency ([50bd59c](50bd59c))
* stick to older match-sorter dependency following strapi ([70dd408](70dd408))
* strapi 4.13 packages alignment ([VirtusLab-Open-Source#229](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/229)) ([3432cd2](3432cd2))
* strapi v4.7.1 compatibility fix because of dependencies ([563f86c](563f86c))
* unused import removed ([ac7d47f](ac7d47f))

* **api:** issue [VirtusLab-Open-Source#209](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/209) - find all by author ([e47684a](e47684a))
* author entity props blocking ([VirtusLab-Open-Source#186](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/186)) ([6134f1e](6134f1e))
* basic filters options added to Discover and Reports ([074d23a](074d23a))
* comments custom field [CU-2tn2923] ([VirtusLab-Open-Source#157](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/157)) ([aaac8a0](aaac8a0)), closes [VirtusLab-Open-Source#158](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/158)
* create reports page [CU-20rfmkv] ([VirtusLab-Open-Source#153](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/153)) ([15b9b57](15b9b57))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a284d59](a284d59))
* typescripted client service and controllers ([eddd4b3](eddd4b3))
github-actions bot pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Dec 20, 2023
# [1.1.0](v1.0.2...v1.1.0) (2023-12-20)

### Bug Fixes

* add types to Avatar component ([f12ea9c](f12ea9c))
* author blocked props ([d9d0777](d9d0777))
* author population ([VirtusLab-Open-Source#177](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/177)) ([5ba0d85](5ba0d85))
* change error 403 test ([99ec162](99ec162))
* custom field on existing entity ([VirtusLab-Open-Source#178](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/178)) ([5e6cc63](5e6cc63))
* fixed UserAvatar typing ([dd179c7](dd179c7))
* fixes after merge ([3b9eee2](3b9eee2))
* issue [VirtusLab-Open-Source#199](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/199) - undeclared codemirror dependency causes build crash ([ccc1f98](ccc1f98))
* issue [VirtusLab-Open-Source#201](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/201) fix the filtering by thread ([bdc292a](bdc292a))
* issue [VirtusLab-Open-Source#220](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/220), issue [VirtusLab-Open-Source#221](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/221) ([VirtusLab-Open-Source#222](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/222)) ([03d504a](03d504a))
* load only existing translations ([e0cea8d](e0cea8d))
* package.json outdated ([1ef26e5](1ef26e5))
* peer dependency ([50bd59c](50bd59c))
* stick to older match-sorter dependency following strapi ([70dd408](70dd408))
* strapi 4.13 packages alignment ([VirtusLab-Open-Source#229](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/229)) ([3432cd2](3432cd2))
* strapi v4.7.1 compatibility fix because of dependencies ([563f86c](563f86c))
* unused import removed ([ac7d47f](ac7d47f))

### Features

* **api:** issue [VirtusLab-Open-Source#209](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/209) - find all by author ([e47684a](e47684a))
* author entity props blocking ([VirtusLab-Open-Source#186](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/186)) ([6134f1e](6134f1e))
* basic filters options added to Discover and Reports ([074d23a](074d23a))
* comments custom field [CU-2tn2923] ([VirtusLab-Open-Source#157](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/157)) ([aaac8a0](aaac8a0)), closes [VirtusLab-Open-Source#158](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/158)
* create reports page [CU-20rfmkv] ([VirtusLab-Open-Source#153](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/153)) ([15b9b57](15b9b57))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a284d59](a284d59))
* typescripted client service and controllers ([eddd4b3](eddd4b3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solved Issue has been solved v4 Strapi v4
Projects
None yet
Development

No branches or pull requests

2 participants