From d8f09a0ad50c69391b4175f3d341f315b82708f7 Mon Sep 17 00:00:00 2001 From: Peter Kese Date: Thu, 27 Oct 2022 02:24:39 +0200 Subject: [PATCH] F#: simplify, add Readme --- Trannet/obj/Trannet.csproj.nuget.dgspec.json | 16 +++++++-------- Trannet/obj/Trannet.csproj.nuget.g.props | 8 ++++---- Trannet/obj/project.assets.json | 14 ++++++------- Trannet/obj/project.nuget.cache | 16 +++++++-------- Trannet/obj/staticwebassets.pack.sentinel | 1 + TransitFs/Program.fs | 21 ++++++++------------ TransitFs/README.md | 3 +++ 7 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 TransitFs/README.md diff --git a/Trannet/obj/Trannet.csproj.nuget.dgspec.json b/Trannet/obj/Trannet.csproj.nuget.dgspec.json index b9f17bb..3fe1389 100644 --- a/Trannet/obj/Trannet.csproj.nuget.dgspec.json +++ b/Trannet/obj/Trannet.csproj.nuget.dgspec.json @@ -1,20 +1,20 @@ { "format": 1, "restore": { - "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj": {} + "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj": {} }, "projects": { - "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj": { + "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj", + "projectUniqueName": "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj", "projectName": "Trannet", - "projectPath": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj", - "packagesPath": "/Users/gabedurazo/.nuget/packages/", - "outputPath": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/obj/", + "projectPath": "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj", + "packagesPath": "/home/peter/.nuget/packages/", + "outputPath": "/home/peter/src/org/transit-lang-cmp/Trannet/obj/", "projectStyle": "PackageReference", "configFilePaths": [ - "/Users/gabedurazo/.nuget/NuGet/NuGet.Config" + "/home/peter/.nuget/NuGet/NuGet.Config" ], "originalTargetFrameworks": [ "net6.0" @@ -62,7 +62,7 @@ "privateAssets": "all" } }, - "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" } } } diff --git a/Trannet/obj/Trannet.csproj.nuget.g.props b/Trannet/obj/Trannet.csproj.nuget.g.props index 9a3f675..67c1bc4 100644 --- a/Trannet/obj/Trannet.csproj.nuget.g.props +++ b/Trannet/obj/Trannet.csproj.nuget.g.props @@ -4,19 +4,19 @@ True NuGet $(MSBuildThisFileDirectory)project.assets.json - /Users/gabedurazo/.nuget/packages/ - /Users/gabedurazo/.nuget/packages/ + /home/peter/.nuget/packages/ + /home/peter/.nuget/packages/ PackageReference 6.3.1 - + - /Users/gabedurazo/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0 + /home/peter/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0 \ No newline at end of file diff --git a/Trannet/obj/project.assets.json b/Trannet/obj/project.assets.json index 3071cb4..ddcef44 100644 --- a/Trannet/obj/project.assets.json +++ b/Trannet/obj/project.assets.json @@ -224,19 +224,19 @@ ] }, "packageFolders": { - "/Users/gabedurazo/.nuget/packages/": {} + "/home/peter/.nuget/packages/": {} }, "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj", + "projectUniqueName": "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj", "projectName": "Trannet", - "projectPath": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj", - "packagesPath": "/Users/gabedurazo/.nuget/packages/", - "outputPath": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/obj/", + "projectPath": "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj", + "packagesPath": "/home/peter/.nuget/packages/", + "outputPath": "/home/peter/src/org/transit-lang-cmp/Trannet/obj/", "projectStyle": "PackageReference", "configFilePaths": [ - "/Users/gabedurazo/.nuget/NuGet/NuGet.Config" + "/home/peter/.nuget/NuGet/NuGet.Config" ], "originalTargetFrameworks": [ "net6.0" @@ -284,7 +284,7 @@ "privateAssets": "all" } }, - "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.402/RuntimeIdentifierGraph.json" } } } diff --git a/Trannet/obj/project.nuget.cache b/Trannet/obj/project.nuget.cache index a1e5640..32ef501 100644 --- a/Trannet/obj/project.nuget.cache +++ b/Trannet/obj/project.nuget.cache @@ -1,15 +1,15 @@ { "version": 2, - "dgSpecHash": "CQxk69YVZIbnCkVRc1bfdGb+ygn+xq5uP2l83B2Ht/bQDoDd7lFpun91OlnR03PKEwFlrNKAhhOj0sHT12HNqA==", + "dgSpecHash": "FrPQrjkXoF5UmH/TbKy6OHADXr/WfYatidIbGSkjkJY+hqNMbclFV4OozCDHVA3m+UUDbikleJA3x364Nu7ZfQ==", "success": true, - "projectFilePath": "/Users/gabedurazo/projects/transit-lang-cmp/Trannet/Trannet.csproj", + "projectFilePath": "/home/peter/src/org/transit-lang-cmp/Trannet/Trannet.csproj", "expectedPackageFiles": [ - "/Users/gabedurazo/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0/microsoft.extensions.apidescription.server.3.0.0.nupkg.sha512", - "/Users/gabedurazo/.nuget/packages/microsoft.openapi/1.2.3/microsoft.openapi.1.2.3.nupkg.sha512", - "/Users/gabedurazo/.nuget/packages/swashbuckle.aspnetcore/6.2.3/swashbuckle.aspnetcore.6.2.3.nupkg.sha512", - "/Users/gabedurazo/.nuget/packages/swashbuckle.aspnetcore.swagger/6.2.3/swashbuckle.aspnetcore.swagger.6.2.3.nupkg.sha512", - "/Users/gabedurazo/.nuget/packages/swashbuckle.aspnetcore.swaggergen/6.2.3/swashbuckle.aspnetcore.swaggergen.6.2.3.nupkg.sha512", - "/Users/gabedurazo/.nuget/packages/swashbuckle.aspnetcore.swaggerui/6.2.3/swashbuckle.aspnetcore.swaggerui.6.2.3.nupkg.sha512" + "/home/peter/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0/microsoft.extensions.apidescription.server.3.0.0.nupkg.sha512", + "/home/peter/.nuget/packages/microsoft.openapi/1.2.3/microsoft.openapi.1.2.3.nupkg.sha512", + "/home/peter/.nuget/packages/swashbuckle.aspnetcore/6.2.3/swashbuckle.aspnetcore.6.2.3.nupkg.sha512", + "/home/peter/.nuget/packages/swashbuckle.aspnetcore.swagger/6.2.3/swashbuckle.aspnetcore.swagger.6.2.3.nupkg.sha512", + "/home/peter/.nuget/packages/swashbuckle.aspnetcore.swaggergen/6.2.3/swashbuckle.aspnetcore.swaggergen.6.2.3.nupkg.sha512", + "/home/peter/.nuget/packages/swashbuckle.aspnetcore.swaggerui/6.2.3/swashbuckle.aspnetcore.swaggerui.6.2.3.nupkg.sha512" ], "logs": [] } \ No newline at end of file diff --git a/Trannet/obj/staticwebassets.pack.sentinel b/Trannet/obj/staticwebassets.pack.sentinel index bca8fe0..b331928 100644 --- a/Trannet/obj/staticwebassets.pack.sentinel +++ b/Trannet/obj/staticwebassets.pack.sentinel @@ -10,3 +10,4 @@ 2.0 2.0 2.0 +2.0 diff --git a/TransitFs/Program.fs b/TransitFs/Program.fs index 94e7124..b9135ce 100644 --- a/TransitFs/Program.fs +++ b/TransitFs/Program.fs @@ -7,9 +7,9 @@ open System.Text.Json.Serialization let dataDir = "../MBTA_GTFS" type Trip = { - tripId: string - routeId: string - serviceId: string + trip_id: string + route_id: string + service_id: string } type StopTime = { @@ -27,12 +27,12 @@ let loadTrips () = while csv.Read() do let routeId = csv.GetString(0) - trips.Add({ routeId=routeId; serviceId=csv.GetString(1); tripId=csv.GetString(2) }) + trips.Add({ route_id=routeId; service_id=csv.GetString(1); trip_id=csv.GetString(2) }) match tripsIxByRoute.TryGetValue routeId with - | true, list -> list.Add(trips.Count - 1); + | true, list -> list.Add(trips.Count - 1) | false, _ -> let list = ResizeArray() - list.Add(trips.Count-1) + list.Add(trips.Count - 1) tripsIxByRoute.Add(routeId, list) trips, tripsIxByRoute @@ -46,7 +46,6 @@ let loadStopTimes () = while csv.Read() do let tripID = csv.GetString(0) stopTimes.Add({ tripId=tripID; arrival_id=csv.GetString(1); departure_id=csv.GetString(2); stop_id=csv.GetString(3) }) - match stopTimesIxByTrip.TryGetValue(tripID) with | true, list -> list.Add(stopTimes.Count - 1) | false, _ -> @@ -85,13 +84,9 @@ webHost [||] { ctx |> Response.ofJson (seq { for tripIx in tripIxs -> let trip = trips[tripIx] - let stopTimeIxs = stopTimesIxByTrip[trip.tripId] - {| - trip_id = trip.tripId - route_id = trip.routeId - service_id = trip.serviceId + let stopTimeIxs = stopTimesIxByTrip[trip.trip_id] + {| trip with schedules = seq { for stopTimeIx in stopTimeIxs -> stopTimes[stopTimeIx] } - //schedules = Array.init stopTimeIxs.Count (fun i -> stopTimes[stopTimeIxs[i]]) |} }) | false, _ -> diff --git a/TransitFs/README.md b/TransitFs/README.md new file mode 100644 index 0000000..a18fbb3 --- /dev/null +++ b/TransitFs/README.md @@ -0,0 +1,3 @@ +To run: + + > dotnet run -c Release \ No newline at end of file