-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add groups for assets #306
Conversation
e943ed6
to
1126661
Compare
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.
😘
@@ -0,0 +1,34 @@ | |||
import { AssetsGroupsBody } from "../../lib/modules/asset/types/AssetGroupContent"; | |||
|
|||
export const assetGroupTestId = "test-group"; |
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.
It's really nitpicking but IMHO the example would be more explicit with "real" hierarchic groups like Occitanie, Montpellier, Ecusson, Rue des écoles Pies
19c03d9
to
5c4d928
Compare
It's hard to review force pushed code. It means re-reading everything, and not just the newly added code |
Ok it's noted, now I rebase only when the review is finished |
Also the documentation is missing, here is some ideas of things to do:
|
0149810
to
5861164
Compare
f73f246
to
411df3d
Compare
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
regexp: { | ||
name: { | ||
case_insensitive: true, | ||
value: body.name, | ||
}, | ||
}, | ||
}, | ||
], | ||
must_not: [ | ||
{ | ||
terms: { | ||
_id: typeof assetId === "string" ? [assetId] : [], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, |
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.
Why not using koncorde syntax ?
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.
I didn't manage to use regexp in case-insensitive mode in Koncorde, the flag i
like it's explain in documentation throw an error and like I haven't the time to search more at the moment I have preferred to use Elasticsearch syntax that works correctly.
But it's true, maybe we need to refactor that later
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.
I dug a little bit and found, that atm, regexp
is not usable in search queries. Because it's not translated from Koncorde DSL to ES DSL (Idk why).
So if we don't implement it (because there are maybe good reasons 🤷), you can either add a comment to explain why we use a ES query, or I also suggest to use the regexp
syntax from ES (yes, therefore you can mix koncorde & es lol):
query: {
and: [
{
regexp: {
name: {
case_insensitive: true,
value: body.name,
},
},
},
{
not: {
"equals": { _id: typeof assetId === "string" ? [assetId] : [] }
}
}
],
},
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.
Koncorde regex and ES regex does not have the same syntax that's why
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.
Koncorde regex and ES regex does not have the same syntax that's why. We could allow the keyword though but it would be confusing since the filter will have ES syntax in Koncorde DSL
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.
I don't understand. Actually the keyword is allowed when searching for documents, via Koncorde.
The query above is working (although it may return an error 🤷)
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.
Koncorde requests are supposed to be used indifferently in realtime filters and in search queries but if you use a regex then it cannot works in both because the syntax is difference
321fecf
to
448e8d7
Compare
* feat(assets-groups): implement CRUD actions * feat(assets-groups): implement add assets to group * feat: implement remove assets to group * feat: export group api types * feat(createGroup): id is not mandatory anymore, auto generated if missing * feat(groupName): add check of name unicity * feat(groupAsset): handle group hierarchy * feat(groupName): check presence of name when create
* feat(assetGroups): implement CRUD actions * feat(assetGroups): implement add assets to group * feat(assetGroups): implement remove assets to group * chore(types): export group api types * feat(createGroup): id is not mandatory anymore, auto generated if missing * feat(groupName): add check of name unicity * feat(groupAsset): handle group hierarchy * feat(groupName): check presence of name when create
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14) ### Bug Fixes * composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8)) * **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c)) ### Features * **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae)) * **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4)) * **assetGroups:** add lastUpdate on changes ([#311](#311)) ([36a4575](36a4575)) * **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14) ### Bug Fixes * composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8)) * **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c)) ### Features * **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae)) * **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4)) * **assetGroups:** add lastUpdate on changes ([#311](#311)) ([36a4575](36a4575)) * **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14) ### Bug Fixes * composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8)) * **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c)) ### Features * **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae)) * **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4)) * **assetGroups:** add lastUpdate on changes ([#311](#311)) ([36a4575](36a4575)) * **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
Depend to #307
What does this PR do ?
This PR implement groups for assets.
The groups can have sub groups and groups can have many assets, but assets can only belong to one group.
How should this be manually tested?
// TODO
Boyscout
Add
@types/lodash
in devDependencies to get autocomplete and correct type on lodash functions