Browse Source

Attempt adding cancelled stops to train scraper

master
Kenneth Bruen 2 years ago
parent
commit
1abb5155e3
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 3
      scraper/src/Models/Station.cs
  2. 3
      scraper/src/Models/Status.cs
  3. 7
      scraper/src/Scrapers/Train.cs

3
scraper/src/Models/Station.cs

@ -37,9 +37,6 @@ namespace InfoferScraper.Models.Station {
}
public interface IStationStatus : IStatus {
new int Delay { get; }
new bool Real { get; }
public bool Cancelled { get; }
public string? Platform { get; }
}

3
scraper/src/Models/Status.cs

@ -6,10 +6,13 @@ namespace InfoferScraper.Models.Status {
/// Determines whether delay was actually reported or is an approximation
/// </summary>
public bool Real { get; }
public bool Cancelled { get; }
}
internal record Status : IStatus {
public int Delay { get; set; }
public bool Real { get; set; }
public bool Cancelled { get; set; }
}
}

7
scraper/src/Scrapers/Train.cs

@ -201,7 +201,12 @@ namespace InfoferScraper.Scrapers {
statusElement.Text().WithCollapsedSpaces(replaceWith: " ")
).Groups as IEnumerable<Group>).Skip(1).Select(group => group.Value);
arrDep.MakeStatus(status => {
status.Delay = string.IsNullOrEmpty(onTime) ? int.Parse(delay) : 0;
if (string.IsNullOrEmpty(onTime) && delay == null) {
status.Cancelled = true;
}
else {
status.Delay = string.IsNullOrEmpty(onTime) ? int.Parse(delay) : 0;
}
status.Real = string.IsNullOrEmpty(approx);
});
}

Loading…
Cancel
Save