Attempt adding cancelled stops to train scraper

This commit is contained in:
Kenneth Bruen 2023-03-02 23:06:26 +01:00
parent 5785e4a98b
commit 1abb5155e3
Signed by: kbruen
GPG key ID: C1980A470C3EE5B1
3 changed files with 9 additions and 4 deletions

View file

@ -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; }
}

View file

@ -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; }
}
}

View file

@ -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);
});
}