Skip to content

Conversation

@xavfernandez
Copy link
Contributor

@xavfernandez xavfernandez commented Nov 18, 2024

🤔 Pourquoi ?

Sinon, ça 💥 avec '>' not supported between instances of 'datetime.date' and 'NoneType'

Cf https://itou.sentry.io/issues/6011765619/?project=6164438 & https://itou-inclusion.slack.com/archives/C01181Y04LT/p1731954611260899 &

🍰 Comment ?

Décrivez en quelques mots la solution retenue et mise en oeuvre, les difficultés ou problèmes rencontrés. Attirez l'attention sur les décisions d'architecture ou de conception importantes.

🚨 À vérifier

  • Mettre à jour le CHANGELOG_breaking_changes.md ?

🏝️ Comment tester

Les instructions pour reproduire le problème, les profils de test, le parcours spécifique à utiliser, etc. Si vous disposez d'une recette jetable, mettre l'URL pour tester dans cette partie.

💻 Captures d'écran

@xavfernandez xavfernandez added the modifié Modifié dans le changelog. label Nov 18, 2024
@xavfernandez xavfernandez self-assigned this Nov 18, 2024
to handle the (common) case of old accepted job applications lacking a
hiring_start_at.
@xavfernandez xavfernandez force-pushed the xfernandez/fix_approval_details branch from 092c7be to 9d72c5e Compare November 18, 2024 20:36
last_hiring = approval.jobapplication_set.accepted().order_by("hiring_start_at").last()
if last_hiring is None or any(
suspension.end_at > last_hiring.hiring_start_at for suspension in long_suspensions
last_hiring_start_at = approval.jobapplication_set.accepted().aggregate(Max("hiring_start_at"))[
Copy link
Contributor

Choose a reason for hiding this comment

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

Pas plus simple de faire ça ?

Suggested change
last_hiring_start_at = approval.jobapplication_set.accepted().aggregate(Max("hiring_start_at"))[
last_hiring = approval.jobapplication_set.accepted().latest("hiring_start_at")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Il faudrait aussi rajouter un .exclude(hiring_start_at=None).
Cf la note de https://docs.djangoproject.com/en/5.1/ref/models/querysets/#django.db.models.query.QuerySet.latest earliest() and latest() may return instances with null dates.
Et je me dis que c'est plus joli de ne demander que la date plutôt que de récupérer toutes les infos de la candidature.

@xavfernandez xavfernandez added this pull request to the merge queue Nov 19, 2024
Merged via the queue into master with commit c30d57e Nov 19, 2024
@xavfernandez xavfernandez deleted the xfernandez/fix_approval_details branch November 19, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug modifié Modifié dans le changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants