Skip to content

Perf/admin reduce company details fetches - #917

Open
rzafari42 wants to merge 19 commits into
masterfrom
perf/admin-reduce-company-details-fetches
Open

Perf/admin reduce company details fetches#917
rzafari42 wants to merge 19 commits into
masterfrom
perf/admin-reduce-company-details-fetches

Conversation

@rzafari42

Copy link
Copy Markdown
Contributor

rzafari42 added 7 commits July 1, 2026 18:06
…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.
@tristanrobert

tristanrobert commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@rzafari42

Copy link
Copy Markdown
Contributor Author

⚠️ A discuter:
Actuellement, sur le dashboard admin, on affiche le nombre total de mission(s) à valider. Par contre, dans la barre de navigation, la pastille « Saisie(s) à valider » affiche uniquement le nombre de mission(s) à valider sur une période d’un mois, ce qui peut être perturbant.
Sur cette PR, j’ai aligné la valeur de la pastille sur celle affichée dans le dashboard.
Est-ce qu’on laisse comme ça, ou est-ce qu’on remet le comportement précédent ?

Comment on lines +28 to +30
if (adminStore.companyId && !adminStore.areEmploymentsLoaded) {
loadEmploymentsData({ adminStore, alerts, api, withLoadingScreen });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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

Comment on lines +29 to +42
}, [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]);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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 ?

Comment thread web/admin/panels/Home.js
Comment on lines +559 to +565
count={
adminStore.areCompanyEssentialsLoaded ? (
adminStore.pendingValidationsCount
) : (
<CircularProgress size={20} />
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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

Comment thread web/admin/utils/loadCompaniesData.js Outdated

@gaspard-lonchampt gaspard-lonchampt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review front de la carte #2343 (perf découpage). Le découpage me semble bien, surtout des questions et quelques petites simplifs possibles 🙂

Comment thread web/admin/utils/teams.js
Comment thread web/admin/panels/Employees.js Outdated
Comment thread web/admin/utils/loadCompaniesData.js Outdated
Comment thread web/admin/utils/loadCompaniesData.js Outdated
Comment thread web/admin/panels/Home.js
Comment thread web/admin/utils/loadCompaniesData.js
Comment thread web/admin/panels/CompanyTeamsPanel.js Fixed
@sonarqubecloud

Copy link
Copy Markdown

@gaspard-lonchampt gaspard-lonchampt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 👍

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