Perf/admin reduce company details fetches - #917
Conversation
…ueries Finish splitting ADMIN_COMPANIES_QUERY into a lightweight essentials payload (fetched on every company selection) and the heavy workdays/missions payload (ADMIN_WORK_DAYS_QUERY), now fetched only once per company, only when the Activities or Validations tab is actually visited, tracked via a new areMissionsActivitiesLoaded flag. - Remove adminRegulationComputationsByUserAndByDay from the essentials query; it was already duplicated in ADMIN_WORK_DAYS_QUERY. - Remove pendingValidationsCount from DASHBOARD_HOME_QUERY; it was already fetched by the essentials query on every company load. Add a dedicated lightweight query to refresh it on manual dashboard refresh and after validating a mission. - Reset areMissionsActivitiesLoaded and areCompanyEssentialsLoaded on company switch so Activities, Validations and Home stop showing the previously selected company's data. - Show a loading indicator on the Home "Mission(s) à valider" tile until the essentials query has resolved for the current company, avoiding a flash of a stale or zero count. - Drop unused imports left over in routes.js.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
|
| if (adminStore.companyId && !adminStore.areEmploymentsLoaded) { | ||
| loadEmploymentsData({ adminStore, alerts, api, withLoadingScreen }); | ||
| } |
There was a problem hiding this comment.
🟠 On a ce guard !adminStore.areEmploymentsLoaded à plusieurs endroits différents, mais si plusieurs de ces composants se montent en même temps on aura quand meme des requêtes loadEmploymentsData en parrallèle. Ce qui serait bien ce serait de mettre en place un areEmploymentsLoading pour préciser que c'est en cours et éviter les appels concurents
| }, [adminStore.companyId]); | ||
|
|
||
| React.useEffect(() => { | ||
| if (adminStore.companyId && !adminStore.areEmploymentsLoaded) { | ||
| loadEmploymentsData({ adminStore, alerts, api, withLoadingScreen }); | ||
| } | ||
| }, [adminStore.companyId]); | ||
|
|
||
| React.useEffect(() => { | ||
| if (adminStore.companyId && !adminStore.areTeamsLoaded) { | ||
| loadTeamsData({ adminStore, alerts, api, withLoadingScreen }); | ||
| } | ||
| }, [adminStore.companyId]); | ||
| }; |
There was a problem hiding this comment.
🟠 Est-ce qu'il ne faudra pas mettre d'autres éléments en dépendance des useEffect comme adminStore.activitiesFilter.minDate ou d'autres champs du store pour s'assurer que ça se mette correctement à jour quand on change les filtres ?
| count={ | ||
| adminStore.areCompanyEssentialsLoaded ? ( | ||
| adminStore.pendingValidationsCount | ||
| ) : ( | ||
| <CircularProgress size={20} /> | ||
| ) | ||
| } |
There was a problem hiding this comment.
🟠 Est-ce qu'on aurait pas un cas où le spinner tourne en boucle ici dans le cas d'un accès direct à admin/home ou si on rafraichis en restant sur cette page areCompanyEssentialsLoaded peut rester à false
gaspard-lonchampt
left a comment
There was a problem hiding this comment.
Review front de la carte #2343 (perf découpage). Le découpage me semble bien, surtout des questions et quelques petites simplifs possibles 🙂
|
gaspard-lonchampt
left a comment
There was a problem hiding this comment.
Tous mes retours sont intégrés (cacheKey teams/activités cohérent, centralisation via useEnsureEmployments, maxDate mort retiré, double-log + newline EOF, badge masqué au lieu d'afficher 0). CI verte, c'est bon pour moi 👍



https://trello.com/c/2mgvBI1u