Skip to content

Commit

Permalink
F#: simplify, add Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pkese committed Oct 27, 2022
1 parent 5f1f2ce commit d8f09a0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 40 deletions.
16 changes: 8 additions & 8 deletions Trannet/obj/Trannet.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Trannet/obj/Trannet.csproj.nuget.g.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/gabedurazo/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/gabedurazo/.nuget/packages/</NuGetPackageFolders>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/peter/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/peter/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.3.1</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/gabedurazo/.nuget/packages/" />
<SourceRoot Include="/home/peter/.nuget/packages/" />
</ItemGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server/3.0.0/build/Microsoft.Extensions.ApiDescription.Server.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server/3.0.0/build/Microsoft.Extensions.ApiDescription.Server.props')" />
<Import Project="$(NuGetPackageRoot)swashbuckle.aspnetcore/6.2.3/build/Swashbuckle.AspNetCore.props" Condition="Exists('$(NuGetPackageRoot)swashbuckle.aspnetcore/6.2.3/build/Swashbuckle.AspNetCore.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgMicrosoft_Extensions_ApiDescription_Server Condition=" '$(PkgMicrosoft_Extensions_ApiDescription_Server)' == '' ">/Users/gabedurazo/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0</PkgMicrosoft_Extensions_ApiDescription_Server>
<PkgMicrosoft_Extensions_ApiDescription_Server Condition=" '$(PkgMicrosoft_Extensions_ApiDescription_Server)' == '' ">/home/peter/.nuget/packages/microsoft.extensions.apidescription.server/3.0.0</PkgMicrosoft_Extensions_ApiDescription_Server>
</PropertyGroup>
</Project>
14 changes: 7 additions & 7 deletions Trannet/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Trannet/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -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": []
}
1 change: 1 addition & 0 deletions Trannet/obj/staticwebassets.pack.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
2.0
2.0
2.0
2.0
21 changes: 8 additions & 13 deletions TransitFs/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand All @@ -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, _ ->
Expand Down Expand Up @@ -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, _ ->
Expand Down
3 changes: 3 additions & 0 deletions TransitFs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To run:

> dotnet run -c Release

0 comments on commit d8f09a0

Please sign in to comment.