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

Fixes #24723: Tree group is slow to load up because it contains the list of nodes in the tree #5621

Conversation

clarktsiory
Copy link
Contributor

@clarktsiory clarktsiory commented Apr 22, 2024

https://issues.rudder.io/issues/24723

Adding an internal groups API and using it instead of the public one.

All the JSON datatype is made with zio-json and chimney, and it is almost the same model as a full group category, because all the information is needed in the Elm app except the node ids.

Also added API tests for that (FYI the tests for the public groups API does not have one for the tree endpoint)

@clarktsiory clarktsiory requested a review from fanf April 22, 2024 10:30
@clarktsiory
Copy link
Contributor Author

PR updated with a new commit

.withFieldComputed(
_.targetInfos,
_.targetInfos.collect {
case t @ FullRuleTargetInfo(_: FullOtherTarget, _, _, _, _) => t.toTargetInfo.transformInto[JRRuleTargetInfo]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FullOtherTarget because group targets are already in groups fields

object JRGroupCategoryInfo {
final case class JRGroupInfo(
id: NodeGroupId,
@jsonField("displayName") name: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this one and other: why not using the json name directly ? Is it an choice given other constraints ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I imagine with chimney, but if so: is there a reason to chose that way ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It avoid a boilerplate for the Transformer definition in chimney : we can derive the field transformation if the name is the same as the source datatype. If we have the displayName field, we would have to write withFieldRenamed(_.displayName, _.name) (it is even more verbose if the transformer could be derive-d directly)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then, you wrote @jsonField("displayName")̀ :) OK, there's less chars in that latter option. And perhaps it's a bit clearer.

override def dataContainer: Option[String] = Some("groupsinternal")
}

object GroupInternalApi extends Enum[GroupInternalApi] with ApiModuleProvider[GroupInternalApi] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for API used for a given (set of page / elm app), we should try to get a nomenclature based on the using app nomenclature.
Plus, we are now officially far far far away from REST and in full RPC land :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think it's ok for that one, and since it's an internal API we can change it whenever we want, but it is something to consider cc @RaphaelGauthier @VinceMacBuche )

Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@Normation-Quality-Assistant
Copy link
Contributor

This PR is not mergeable to upper versions.
Since it is "Ready for merge" you must merge it by yourself using the following command:
rudder-dev merge https://github.com/Normation/rudder/pull/5621
-- Your faithful QA
Kant merge: "Live your life as though your every act were to become a universal law."
(https://ci.normation.com/jenkins/job/merge-accepted-pr/83621/console)

@amousset
Copy link
Member

OK, squash merging this PR

@amousset amousset force-pushed the bug_24723/tree_group_is_slow_to_load_up_because_it_contains_the_list_of_nodes_in_the_tree branch from d13daeb to 253f1d3 Compare April 22, 2024 17:11
@amousset amousset merged commit 253f1d3 into Normation:branches/rudder/8.1 Apr 22, 2024
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants