Skip to content

[IA-5072] n+1 queries on Form submissions#3034

Open
Crebert08 wants to merge 12 commits into
developfrom
IA-5072-n+1-queries-on-map-tab
Open

[IA-5072] n+1 queries on Form submissions#3034
Crebert08 wants to merge 12 commits into
developfrom
IA-5072-n+1-queries-on-map-tab

Conversation

@Crebert08
Copy link
Copy Markdown
Contributor

@Crebert08 Crebert08 commented May 19, 2026

What problem is this PR solving?

This PR is about fixing the n+1 issues on the map tab on the form submissions list

Related JIRA tickets

IA-5072

Changes

Map tab

  • For the map context, there is no need for pagination and no need to return the as_dict format, so I implemented a function to return id and location only in /home/crebert/Desktop/iaso/iaso/api/instances/views.py
  • Added the new location type in /home/crebert/Desktop/iaso/hat/assets/js/apps/Iaso/domains/instances/types/instance.ts
  • Defined a new request for the map tab in /home/crebert/Desktop/iaso/hat/assets/js/apps/Iaso/domains/instances/requests.ts
  • Added a new endpoint
  • Added some tests

List Tab

  • Added an annotation on the queryset in /home/crebert/Desktop/iaso/iaso/api/instances/views.py
  • Added a fallback in the properties in /home/crebert/Desktop/iaso/iaso/models/instances.py
  • Added a test and fixed one in /home/crebert/Desktop/iaso/iaso/tests/api/instances/test_instances.py

How to test

Explain how to test your PR.

//

Print screen / video

Map tab

The queries go from this:
image

To this:
image

List tab

The queries go from this:
image

To this:
image

Notes

Things that the reviewers should know:

  • known bugs that are out of the scope of the PR
  • other trade-offs that were made
  • does the PR depends on a PR in bluesquare-components?
  • should the PR be merged into another PR?

Doc

Tell us where the doc can be found (docs folder, wiki, in the code...).

@Crebert08 Crebert08 changed the title Ia 5072 n+1 queries on map tab IA-5072 n+1 queries on map tab May 19, 2026
@Crebert08 Crebert08 changed the title IA-5072 n+1 queries on map tab [IA-5072] n+1 queries on map tab May 19, 2026
@Crebert08 Crebert08 marked this pull request as ready for review May 19, 2026 09:43
@Crebert08 Crebert08 requested review from beygorghor and hugo093 May 19, 2026 09:43
Copy link
Copy Markdown
Contributor

@hugo093 hugo093 left a comment

Choose a reason for hiding this comment

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

good job , the query count drop is quite impressive.
However, some changes are needed imho: coding and "structural"

Comment thread iaso/api/instances/views.py Outdated
Comment thread iaso/tests/api/instances/test_instances.py Outdated
Comment thread hat/assets/js/apps/Iaso/domains/instances/index.tsx
Comment thread iaso/api/instances/views.py Outdated
@Crebert08 Crebert08 requested review from hugo093 and quang-le May 20, 2026 13:35
Copy link
Copy Markdown
Contributor

@hugo093 hugo093 left a comment

Choose a reason for hiding this comment

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

few code changes, for cleanliness :) otherwise lgtm

Comment thread iaso/api/instances/views.py Outdated
Comment thread iaso/api/instances/serializers/misc.py Outdated
Comment thread iaso/api/instances/serializers/misc.py
@Crebert08 Crebert08 requested a review from hugo093 May 21, 2026 09:22
Copy link
Copy Markdown
Collaborator

@beygorghor beygorghor left a comment

Choose a reason for hiding this comment

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

i'm still having lot's of duplicate on the non map endpoint

Image

Comment thread hat/assets/js/apps/Iaso/domains/instances/index.tsx
Copy link
Copy Markdown
Contributor

@hugo093 hugo093 left a comment

Choose a reason for hiding this comment

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

for my part and the comments I had, LGTM. I'll let the others review :) Thanks for the changes

@Crebert08 Crebert08 changed the title [IA-5072] n+1 queries on map tab [IA-5072] n+1 queries on Form submissions May 22, 2026
@Crebert08 Crebert08 requested review from beygorghor and hugo093 May 22, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants