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. 5
      scraper/src/Scrapers/Train.cs

3
scraper/src/Models/Station.cs

@ -37,9 +37,6 @@ namespace InfoferScraper.Models.Station {
} }
public interface IStationStatus : IStatus { public interface IStationStatus : IStatus {
new int Delay { get; }
new bool Real { get; }
public bool Cancelled { get; }
public string? Platform { 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 /// Determines whether delay was actually reported or is an approximation
/// </summary> /// </summary>
public bool Real { get; } public bool Real { get; }
public bool Cancelled { get; }
} }
internal record Status : IStatus { internal record Status : IStatus {
public int Delay { get; set; } public int Delay { get; set; }
public bool Real { get; set; } public bool Real { get; set; }
public bool Cancelled { get; set; }
} }
} }

5
scraper/src/Scrapers/Train.cs

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

Loading…
Cancel
Save