aboutsummaryrefslogtreecommitdiff
path: root/src/Enmarcha.Backend/Services/FeedService.cs
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2026-03-15 23:01:32 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2026-03-15 23:01:32 +0100
commit99005bce74288a415ac748414e0f8b522e207c93 (patch)
tree2aacb51f1ebbd58a687b176ed81dc240970db878 /src/Enmarcha.Backend/Services/FeedService.cs
parentc0e758b1e793159fc86c85916130f8959360c64e (diff)
feat: enhance arrival processing with shift badge retrieval and deletion flag
Diffstat (limited to 'src/Enmarcha.Backend/Services/FeedService.cs')
-rw-r--r--src/Enmarcha.Backend/Services/FeedService.cs39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/Enmarcha.Backend/Services/FeedService.cs b/src/Enmarcha.Backend/Services/FeedService.cs
index dc016b4..c3e33fd 100644
--- a/src/Enmarcha.Backend/Services/FeedService.cs
+++ b/src/Enmarcha.Backend/Services/FeedService.cs
@@ -217,10 +217,45 @@ public class FeedService
return HiddenStops.Contains(stopId);
}
- public ShiftBadge? GetShiftBadge(string feedId, string tripId)
+ public static ShiftBadge? GetShiftBadge(string feedId, string tripId)
{
- if (feedId != "vitrasa") return null;
+ return feedId switch
+ {
+ "vitrasa" => GetVitrasaShiftBadge(tripId.Split(':', 2)[1]),
+ "tranvias" => GetTranviasShiftBadge(tripId.Split(':', 2)[1]),
+ _ => null
+ };
+ }
+
+ private static ShiftBadge? GetTranviasShiftBadge(string tripId)
+ {
+ // Example: 200032223 || 2301032230
+ var padded = tripId.PadLeft(10);
+
+ Console.WriteLine(padded[4..6]);
+
+ var dayOfWeek = padded[4..6] switch
+ {
+ "01" => "Lab",
+ "02" => "Sab",
+ "03" => "Dom",
+ "04" => "Fes",
+ "05" or "06" or "07" => "NoLec",
+ "08" => "Ex.UDC",
+ "09" => "Desc",
+ "10" => "Navid",
+ _ => ""
+ };
+
+ return new ShiftBadge
+ {
+ ShiftName = padded[..4].Trim(),
+ ShiftTrip = $"{dayOfWeek} {padded[6..]}",
+ };
+ }
+ private static ShiftBadge? GetVitrasaShiftBadge(string tripId)
+ {
// Example: C1 04LN 02_001004_4
var parts = tripId.Split('_');
if (parts.Length < 2) return null;