Skip to content

Afficher les alertes de trafic #40

Open
@AymenFarrah

Description

@AymenFarrah

Bonjour

Je voudrais bien faire une pull request mais j'ai pas réussi a en créer.

L'idée étant d'afficher l'alerte de trafic la plus récente pour être plus conforme à ce qu'affiche la RATP comme information.

Pour y arriver je propose ce code dans le service RatpTrafficService.php

// Collect specific errors : Travaux
if (isset($errors['Travaux'])) {
    array_push($events, current($errors['Travaux']));                         
} 
// Collect specific errors : Incident
if (isset($errors['Incidents techniques'])) {
    array_push($events, current($errors['Incidents techniques']));
} 
// Collect specific errors : Grève
if (isset($errors['Mouvement social'])) {
    array_push($events, current($errors['Mouvement social']));                        
} 
// If no specific errors ! Collect all available errors
if (empty($events)) {
    $events = current($errors);
}
// Sort events to get the recent event on top
usort($events, function ($event1, $event2) {
    return $event2['startDate'] <=> $event1['startDate'];
}
// Take the first event on the events list (the recent one)
$event = reset($events);
  • L' information donnée par la RATP en capture ici :

Capture d’écran 2021-11-15 à 21 10 28

  • La version d'API actuelle donne ça :

Capture d’écran 2021-11-15 à 21 02 23

- La version avec mon fix donne ça :

Capture d’écran 2021-11-15 à 21 02 31

Merci !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions