Version 3.4 #78
@ -1,17 +1,17 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||||
WORKDIR /mpj
|
WORKDIR /mpj
|
||||||
COPY ./MyPrayerJournal/MyPrayerJournal.fsproj ./
|
COPY ./MyPrayerJournal/MyPrayerJournal.fsproj ./
|
||||||
RUN dotnet restore
|
RUN dotnet restore
|
||||||
|
|
||||||
COPY ./MyPrayerJournal ./
|
COPY ./MyPrayerJournal ./
|
||||||
RUN dotnet publish -c Release -r linux-x64
|
RUN dotnet publish -c Release -r linux-x64
|
||||||
RUN rm bin/Release/net7.0/linux-x64/publish/appsettings.*.json
|
RUN rm bin/Release/net8.0/linux-x64/publish/appsettings.*.json
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine as final
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine as final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk add --no-cache icu-libs
|
RUN apk add --no-cache icu-libs
|
||||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||||
COPY --from=build /mpj/bin/Release/net7.0/linux-x64/publish/ ./
|
COPY --from=build /mpj/bin/Release/net8.0/linux-x64/publish/ ./
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD [ "dotnet", "/app/MyPrayerJournal.dll" ]
|
CMD [ "dotnet", "/app/MyPrayerJournal.dll" ]
|
@ -28,12 +28,11 @@ module Json =
|
|||||||
/// JSON serializer options to support the target domain
|
/// JSON serializer options to support the target domain
|
||||||
let options =
|
let options =
|
||||||
let opts = JsonSerializerOptions()
|
let opts = JsonSerializerOptions()
|
||||||
[ WrappedJsonConverter(Recurrence.ofString, Recurrence.toString) :> JsonConverter
|
[ WrappedJsonConverter(Recurrence.ofString, Recurrence.toString) :> JsonConverter
|
||||||
WrappedJsonConverter(RequestAction.ofString, RequestAction.toString)
|
WrappedJsonConverter(RequestAction.ofString, RequestAction.toString)
|
||||||
WrappedJsonConverter(RequestId.ofString, RequestId.toString)
|
WrappedJsonConverter(RequestId.ofString, RequestId.toString)
|
||||||
WrappedJsonConverter(UserId, UserId.toString)
|
WrappedJsonConverter(UserId, UserId.toString)
|
||||||
JsonFSharpConverter()
|
JsonFSharpConverter() ]
|
||||||
]
|
|
||||||
|> List.iter opts.Converters.Add
|
|> List.iter opts.Converters.Add
|
||||||
let _ = opts.ConfigureForNodaTime NodaTime.DateTimeZoneProviders.Tzdb
|
let _ = opts.ConfigureForNodaTime NodaTime.DateTimeZoneProviders.Tzdb
|
||||||
opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
|
opts.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
|
||||||
@ -41,13 +40,13 @@ module Json =
|
|||||||
opts
|
opts
|
||||||
|
|
||||||
|
|
||||||
open BitBadger.Npgsql.FSharp.Documents
|
open BitBadger.Documents.Postgres
|
||||||
|
|
||||||
/// Connection
|
/// Connection
|
||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
module Connection =
|
module Connection =
|
||||||
|
|
||||||
open BitBadger.Npgsql.Documents
|
open BitBadger.Documents
|
||||||
open Microsoft.Extensions.Configuration
|
open Microsoft.Extensions.Configuration
|
||||||
open Npgsql
|
open Npgsql
|
||||||
open System.Text.Json
|
open System.Text.Json
|
||||||
@ -55,8 +54,8 @@ module Connection =
|
|||||||
/// Ensure the database is ready to use
|
/// Ensure the database is ready to use
|
||||||
let private ensureDb () = backgroundTask {
|
let private ensureDb () = backgroundTask {
|
||||||
do! Custom.nonQuery "CREATE SCHEMA IF NOT EXISTS mpj" []
|
do! Custom.nonQuery "CREATE SCHEMA IF NOT EXISTS mpj" []
|
||||||
do! Definition.ensureTable Table.Request
|
do! Definition.ensureTable Table.Request
|
||||||
do! Definition.ensureIndex Table.Request Optimized
|
do! Definition.ensureDocumentIndex Table.Request Optimized
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set up the data environment
|
/// Set up the data environment
|
||||||
@ -89,7 +88,7 @@ module Request =
|
|||||||
|
|
||||||
/// Retrieve a request by its ID and user ID
|
/// Retrieve a request by its ID and user ID
|
||||||
let tryById reqId userId = backgroundTask {
|
let tryById reqId userId = backgroundTask {
|
||||||
match! Find.byId<Request> Table.Request (RequestId.toString reqId) with
|
match! Find.byId<string, Request> Table.Request (RequestId.toString reqId) with
|
||||||
| Some req when req.UserId = userId -> return Some req
|
| Some req when req.UserId = userId -> return Some req
|
||||||
| _ -> return None
|
| _ -> return None
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ module Request =
|
|||||||
let updateRecurrence reqId userId (recurType : Recurrence) = backgroundTask {
|
let updateRecurrence reqId userId (recurType : Recurrence) = backgroundTask {
|
||||||
let dbId = RequestId.toString reqId
|
let dbId = RequestId.toString reqId
|
||||||
match! existsById reqId userId with
|
match! existsById reqId userId with
|
||||||
| true -> do! Update.partialById Table.Request dbId {| Recurrence = recurType |}
|
| true -> do! Patch.byId Table.Request dbId {| Recurrence = recurType |}
|
||||||
| false -> invalidOp $"Request ID {dbId} not found"
|
| false -> invalidOp $"Request ID {dbId} not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ module Request =
|
|||||||
let updateShowAfter reqId userId (showAfter : Instant option) = backgroundTask {
|
let updateShowAfter reqId userId (showAfter : Instant option) = backgroundTask {
|
||||||
let dbId = RequestId.toString reqId
|
let dbId = RequestId.toString reqId
|
||||||
match! existsById reqId userId with
|
match! existsById reqId userId with
|
||||||
| true -> do! Update.partialById Table.Request dbId {| ShowAfter = showAfter |}
|
| true -> do! Patch.byId Table.Request dbId {| ShowAfter = showAfter |}
|
||||||
| false -> invalidOp $"Request ID {dbId} not found"
|
| false -> invalidOp $"Request ID {dbId} not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ module Request =
|
|||||||
let updateSnoozed reqId userId (until : Instant option) = backgroundTask {
|
let updateSnoozed reqId userId (until : Instant option) = backgroundTask {
|
||||||
let dbId = RequestId.toString reqId
|
let dbId = RequestId.toString reqId
|
||||||
match! existsById reqId userId with
|
match! existsById reqId userId with
|
||||||
| true -> do! Update.partialById Table.Request dbId {| SnoozedUntil = until; ShowAfter = until |}
|
| true -> do! Patch.byId Table.Request dbId {| SnoozedUntil = until; ShowAfter = until |}
|
||||||
| false -> invalidOp $"Request ID {dbId} not found"
|
| false -> invalidOp $"Request ID {dbId} not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,8 +127,7 @@ module History =
|
|||||||
let dbId = RequestId.toString reqId
|
let dbId = RequestId.toString reqId
|
||||||
match! Request.tryById reqId userId with
|
match! Request.tryById reqId userId with
|
||||||
| Some req ->
|
| Some req ->
|
||||||
do! Update.partialById Table.Request dbId
|
do! Patch.byId Table.Request dbId {| History = (hist :: req.History) |> List.sortByDescending (_.AsOf) |}
|
||||||
{| History = (hist :: req.History) |> List.sortByDescending (_.AsOf) |}
|
|
||||||
| None -> invalidOp $"Request ID {dbId} not found"
|
| None -> invalidOp $"Request ID {dbId} not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,9 +141,9 @@ module Journal =
|
|||||||
let! reqs =
|
let! reqs =
|
||||||
Custom.list
|
Custom.list
|
||||||
$"""{Query.Find.byContains Table.Request} AND {Query.whereJsonPathMatches "@stat"}"""
|
$"""{Query.Find.byContains Table.Request} AND {Query.whereJsonPathMatches "@stat"}"""
|
||||||
[ "@criteria", Query.jsonbDocParam {| UserId = userId |}
|
[ jsonParam "@criteria" {| UserId = userId |}
|
||||||
"@stat", Sql.string """$.history[0].status ? (@ == "Answered")"""
|
"@stat", Sql.string """$.history[0].status ? (@ == "Answered")""" ]
|
||||||
] fromData<Request>
|
fromData<Request>
|
||||||
return
|
return
|
||||||
reqs
|
reqs
|
||||||
|> Seq.ofList
|
|> Seq.ofList
|
||||||
@ -160,9 +158,9 @@ module Journal =
|
|||||||
let! reqs =
|
let! reqs =
|
||||||
Custom.list
|
Custom.list
|
||||||
$"""{Query.Find.byContains Table.Request} AND {Query.whereJsonPathMatches "@stat"}"""
|
$"""{Query.Find.byContains Table.Request} AND {Query.whereJsonPathMatches "@stat"}"""
|
||||||
[ "@criteria", Query.jsonbDocParam {| UserId = userId |}
|
[ jsonParam "@criteria" {| UserId = userId |}
|
||||||
"@stat", Sql.string """$.history[0].status ? (@ <> "Answered")"""
|
"@stat", Sql.string """$.history[0].status ? (@ <> "Answered")""" ]
|
||||||
] fromData<Request>
|
fromData<Request>
|
||||||
return
|
return
|
||||||
reqs
|
reqs
|
||||||
|> Seq.ofList
|
|> Seq.ofList
|
||||||
@ -193,8 +191,7 @@ module Note =
|
|||||||
let dbId = RequestId.toString reqId
|
let dbId = RequestId.toString reqId
|
||||||
match! Request.tryById reqId userId with
|
match! Request.tryById reqId userId with
|
||||||
| Some req ->
|
| Some req ->
|
||||||
do! Update.partialById Table.Request dbId
|
do! Patch.byId Table.Request dbId {| Notes = (note :: req.Notes) |> List.sortByDescending (_.AsOf) |}
|
||||||
{| Notes = (note :: req.Notes) |> List.sortByDescending (_.AsOf) |}
|
|
||||||
| None -> invalidOp $"Request ID {dbId} not found"
|
| None -> invalidOp $"Request ID {dbId} not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,15 +20,16 @@
|
|||||||
<Compile Include="Program.fs" />
|
<Compile Include="Program.fs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BitBadger.Npgsql.FSharp.Documents" Version="2.0.0" />
|
<PackageReference Include="BitBadger.Documents.Postgres" Version="3.1.0" />
|
||||||
<PackageReference Include="FSharp.SystemTextJson" Version="1.2.42" />
|
<PackageReference Include="FSharp.SystemTextJson" Version="1.3.13" />
|
||||||
<PackageReference Include="FunctionalCuid" Version="1.0.0" />
|
<PackageReference Include="FunctionalCuid" Version="1.0.0" />
|
||||||
<PackageReference Include="Giraffe" Version="6.2.0" />
|
<PackageReference Include="Giraffe" Version="6.4.0" />
|
||||||
<PackageReference Include="Giraffe.Htmx" Version="1.9.8" />
|
<PackageReference Include="Giraffe.Htmx" Version="1.9.12" />
|
||||||
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.9.8" />
|
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.9.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.6" />
|
||||||
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
|
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.2.0" />
|
||||||
<PackageReference Include="Npgsql.NodaTime" Version="8.0.1" />
|
<PackageReference Include="Npgsql.NodaTime" Version="8.0.3" />
|
||||||
|
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="wwwroot\" />
|
<Folder Include="wwwroot\" />
|
||||||
|
Loading…
Reference in New Issue
Block a user