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

Normalize data in same place #65

Open
Merkur39 opened this issue Feb 23, 2022 · 0 comments
Open

Normalize data in same place #65

Merkur39 opened this issue Feb 23, 2022 · 0 comments
Labels
✨ enhancement New feature or request

Comments

@Merkur39
Copy link
Member

Aujourd'hui nous avons une fonction getSectionsInfo qui nous retourne :

return {
  id: feature.id,
  mode: getFeatureMode(feature),
  distance: get(feature, 'properties.distance'), // in meters
  duration: get(feature, 'properties.duration'), // in seconds
  startDate: get(feature, 'properties.start_fmt_time'),
  endDate: get(feature, 'properties.end_fmt_time'),
  averageSpeed: speeds ? averageSpeedKmH(speeds) : undefined // in km/h
}

Et une autre getSectionsFormatedInfo qui nous retourne :

const sections = getSectionsInfo(trip)
return sections.map(section => {
  return {
    ...section,
    distance: `${formatDistance(section.distance)}`,
    duration: `${humanizeDuration(section.duration * 1000, { ... })}`,
    averageSpeed: `${Math.round(section.averageSpeed)} km/h`
  }
})

Je propose les points d'améliorations suivant :

  • Fonction getSectionsInfo :

    • averageSpeed devrait être remplacée par speeds
    • mode devrait être remplacée par manualMode & sensedMode
  • Fonction getSectionsFormatedInfo :

    • Elle devrait retourner ces props en plus (sans oublier le refacto d'averageSpeed) :
startDate: isValidDate(new Date(section.startDate)) ? startDate : null,
endDate: isValidDate(new Date(section.startDate)) ? endDate : null,
mode: getFeatureMode(section.manualMode, section.sensedMode),

Ca demandera certainement quelques "petits" refacto supplémentaires, mais je pense qu'il serait plus sage de

  • ne pas perdre des données (ex: mode)
  • mieux compartimenter le type de nos données
@Merkur39 Merkur39 added the ✨ enhancement New feature or request label Feb 23, 2022
@Merkur39 Merkur39 mentioned this issue Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant