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

fix(dashboard): nouveau DataLoader #1692

Merged
merged 14 commits into from
Oct 10, 2023
Merged

fix(dashboard): nouveau DataLoader #1692

merged 14 commits into from
Oct 10, 2023

Conversation

arnaudambro
Copy link
Contributor

@arnaudambro arnaudambro commented Oct 3, 2023

proposition:

cache

Le dataloader ne gère pas le cache: c'est géré par Recoil à 100%, avec une valeur par défault async et un effect onSet. Ainsi, le dataloader ne gère que les states recoil.

Exemple:

export const territoriesState = atom({
   key:'territory',
   default: selector({
     key: 'territory/default',
     get: async () => {
       const cache = await getCacheItemDefaultValue('territory', []);
       return cache;
     },
   }),
   effects: [({ onSet }) => onSet(async (newValue) => setCacheItem(collectionName, newValue))],
 });

téléchargement des batchs de données

un exemple est plus parlant, reproduit pour chaque table

      let newItems = [];
      setLoadingText('Chargement des personnes');
      async function loadPersons(page = 0) {
        const res = await API.get({ path: '/person', query: { ...query, page: String(page) } });
        if (!res.ok || !res.data.length) return resetLoaderOnError();
        setProgress((p) => p + res.data.length);
        newItems.push(...res.decryptedData);
        if (res.hasMore) return loadPersons(page + 1);
        setPersons(mergeItems(persons, newItems));
        return true;
      }
      const personSuccess = await loadPersons(0);
      if (!personSuccess) return false;

avantage niveau performances

  • on appelle une seule fois par table mergeItems
  • on appelle une seule fois par table le recoil setter

mois de bugs ?

je ne sais pas...
il faudrait imaginer pourquoi parfois on a des problèmes de cache avec le loader actuel, qu'on arrive jamais à reproduire de notre côté.

  • j'ai imaginé que la requête /organisation/stats pouvait parfois être trop longue, qui fait que pendant cette requête, des données sont créées qui ne seront jamais prises en compte -> j'ai bougé API.get({ path: '/now' }); après cette requête de stats, ce qui fait que le risque est un peu diminué ?
  • j'ai modifié le withDeleted parce que je n'ai pas compris pourquoi on voulait les éléments supprimés SEULEMENT si le lastRefresh > 0. C'est moi qui ait mis ça au début, mais là je ne comprends pas la logique, donc j'ai mis withDeleted: true tout le temps.
  • je n'ai pas d'autre explication

voilà, à part ça je ne vois pas grand chose d'autre à rajouter pour l'instant.

ouvert aux critiques/remarques/améliorations/etc. !

@arnaudambro arnaudambro temporarily deployed to review-auto October 3, 2023 19:44 — with GitHub Actions Inactive
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@arnaudambro arnaudambro temporarily deployed to review-auto October 3, 2023 20:26 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 5, 2023 07:11 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 5, 2023 12:36 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 5, 2023 18:55 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 6, 2023 07:14 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 6, 2023 07:21 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 6, 2023 07:44 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 6, 2023 08:41 — with GitHub Actions Inactive
Copy link
Member

@rap2hpoutre rap2hpoutre left a comment

Choose a reason for hiding this comment

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

J'ai une réelle crainte sur un zéro length mais tout le reste me semble bon.
J'ai surtout posé des questions parce que je remet le nez dans mano après plus de 6 mois...

api/src/controllers/organisation.js Show resolved Hide resolved
api/src/controllers/organisation.js Show resolved Hide resolved
dashboard/src/app.js Show resolved Hide resolved
dashboard/src/app.js Show resolved Hide resolved
dashboard/src/components/DataLoader.js Show resolved Hide resolved
dashboard/src/components/DataLoader.js Outdated Show resolved Hide resolved
dashboard/src/components/DataLoader.js Show resolved Hide resolved
dashboard/src/components/DataLoader.js Show resolved Hide resolved
dashboard/src/components/DataLoader.js Show resolved Hide resolved
dashboard/src/recoil/selectors.js Show resolved Hide resolved
@arnaudambro arnaudambro temporarily deployed to review-auto October 9, 2023 14:48 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 9, 2023 15:23 — with GitHub Actions Inactive
@arnaudambro arnaudambro temporarily deployed to review-auto October 9, 2023 17:57 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

🎉 Deployment for commit a07c453 :

Ingresses
Docker images
  • 📦 docker pull harbor.fabrique.social.gouv.fr/mano/mano/api:sha-a07c453205413e7a0df259663301c19ff97389a7
  • 📦 docker pull harbor.fabrique.social.gouv.fr/mano/mano/dashboard:sha-a07c453205413e7a0df259663301c19ff97389a7
  • 📦 docker pull harbor.fabrique.social.gouv.fr/mano/mano/www:sha-a07c453205413e7a0df259663301c19ff97389a7
Debug

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@arnaudambro arnaudambro merged commit fa8c753 into main Oct 10, 2023
5 of 6 checks passed
@arnaudambro arnaudambro deleted the fix/dataloader branch October 10, 2023 02:52
SocialGroovyBot added a commit that referenced this pull request Oct 10, 2023
## [1.288.5](v1.288.4...v1.288.5) (2023-10-10)

### Bug Fixes

* **dashboard:** nouveau DataLoader ([#1692](#1692)) ([fa8c753](fa8c753))
@SocialGroovyBot
Copy link
Member

🎉 This PR is included in version 1.288.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants