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

Hot fix : améliorer la perf de la page "mes cantines" #3955

Merged
merged 1 commit into from
May 30, 2024

Conversation

hfroot
Copy link
Collaborator

@hfroot hfroot commented May 27, 2024

Suite à une PR qui a ajouté quelques champs complèxes sur le FullCanteenSerializer, il y a un interêt d'avoir un nouveau endpoint pour la pagination des cantines. Sur staging je c'est bcp trop lente.

Avant : 1.68s; après : 138 ms

Screenshot 2024-05-27 at 15 14 31
Screenshot 2024-05-27 at 15 45 29

idéalement on fera en deuxième temps une refacto des serializers et endpoints pour voir lesquels on pourrait merger, quoi on a qui est maintenant redondant #3956

"central_kitchen_diagnostics", # can return a TD status instead of diagnostics
)
fields = my_fields
read_only_fields = my_fields
Copy link
Collaborator

@qloridant qloridant May 27, 2024

Choose a reason for hiding this comment

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

On ne peut pas directement écrire read_only_fields = (... ) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

comme

fields = ("id", "name",...)
read_only_fields = ("id", "name",...)

?
Oui on peut, je n'aime pas la repetition


class Meta:
model = Canteen
my_fields = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
my_fields = (
read_only_fields = (
"id",
"name",
"city",
"city_insee_code",
"postal_code",
"sectors",
"daily_meal_count",
"yearly_meal_count",
"siret",
"management_type",
"production_type",
"department",
"region",
"publication_status",
"economic_model",
"is_central_cuisine",
"modification_date",
# the following can still be improved
"images", # can return the first image only
"diagnostics",
"central_kitchen_diagnostics", # can return a TD status instead of diagnostics
)

@hfroot hfroot merged commit 82b8d0b into staging May 30, 2024
5 checks passed
@hfroot hfroot deleted the canteen-manager-perf branch May 30, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Test done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants