Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cce4f17cd8 | |||
| 0bf73e49c9 | |||
| a84d54c095 | |||
|
|
68f4a1b9b2 | ||
| 23ccd3ac67 | |||
| d4823c15f7 | |||
| fc01e79337 | |||
| fa9c902af7 | |||
|
|
ed762ea03e | ||
| 3675af3dca | |||
|
|
1830e01ad6 | ||
|
|
ffe057d7ee | ||
|
|
bafdfb1af5 | ||
|
|
3d907e9569 | ||
|
|
c8ef6e8714 | ||
| 92a493251a | |||
| c7c63d01f8 | |||
|
|
62a18a8b09 | ||
| d1a9eb62c3 | |||
| 407222d06a | |||
| 044283709c | |||
|
|
be86fbfcba | ||
|
|
63b3037ede | ||
| d239b16d33 | |||
| a9ab0446c4 | |||
| 366ed2ed2f | |||
|
|
fb304c26b6 | ||
|
|
7b11e70e76 | ||
|
|
f50a8ae83e | ||
|
|
aa0864416f | ||
|
|
05a1b7adda | ||
|
|
f833598cdd | ||
|
|
dfd1c59554 | ||
|
|
83b70073e9 | ||
|
|
11025cc39a | ||
|
|
fb908a1cef | ||
|
|
6a6f7b35c7 | ||
| 715df08cbe | |||
|
|
ac8b39fff9 | ||
|
|
2bf54136ca | ||
|
|
0709cabea1 | ||
|
|
cbd9114599 | ||
|
|
097ee2deb4 |
@@ -126,8 +126,8 @@ module Data =
|
|||||||
.ToListAsync()
|
.ToListAsync()
|
||||||
return
|
return
|
||||||
jrnl
|
jrnl
|
||||||
|
|> Seq.map (fun r -> r.history <- []; r.notes <- []; r)
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|> List.map (fun r -> r.history <- []; r.notes <- []; r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save changes in the current document session
|
/// Save changes in the current document session
|
||||||
@@ -166,7 +166,9 @@ module Data =
|
|||||||
.Where(fun x -> x.Id = (RequestId.toString reqId) && x.userId = userId)
|
.Where(fun x -> x.Id = (RequestId.toString reqId) && x.userId = userId)
|
||||||
.ProjectInto<JournalRequest>()
|
.ProjectInto<JournalRequest>()
|
||||||
.FirstOrDefaultAsync ()
|
.FirstOrDefaultAsync ()
|
||||||
return Option.fromObject req
|
return
|
||||||
|
Option.fromObject req
|
||||||
|
|> Option.map (fun r -> r.history <- []; r.notes <- []; r)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the recurrence for a request
|
/// Update the recurrence for a request
|
||||||
|
|||||||
@@ -86,6 +86,15 @@ module private Helpers =
|
|||||||
let asJson<'T> next ctx (o : 'T) =
|
let asJson<'T> next ctx (o : 'T) =
|
||||||
json o next ctx
|
json o next ctx
|
||||||
|
|
||||||
|
/// Work-around to let the Json.NET serializer synchronously deserialize from the request stream
|
||||||
|
// TODO: Remove this once there is an async serializer
|
||||||
|
let allowSyncIO : HttpHandler =
|
||||||
|
fun next ctx ->
|
||||||
|
match ctx.Features.Get<Features.IHttpBodyControlFeature>() with
|
||||||
|
| null -> ()
|
||||||
|
| f -> f.AllowSynchronousIO <- true
|
||||||
|
next ctx
|
||||||
|
|
||||||
|
|
||||||
/// Strongly-typed models for post requests
|
/// Strongly-typed models for post requests
|
||||||
module Models =
|
module Models =
|
||||||
@@ -156,6 +165,7 @@ module Request =
|
|||||||
/// POST /api/request
|
/// POST /api/request
|
||||||
let add : HttpHandler =
|
let add : HttpHandler =
|
||||||
authorize
|
authorize
|
||||||
|
>=> allowSyncIO
|
||||||
>=> fun next ctx ->
|
>=> fun next ctx ->
|
||||||
task {
|
task {
|
||||||
let! r = ctx.BindJsonAsync<Models.Request> ()
|
let! r = ctx.BindJsonAsync<Models.Request> ()
|
||||||
@@ -187,6 +197,7 @@ module Request =
|
|||||||
/// POST /api/request/[req-id]/history
|
/// POST /api/request/[req-id]/history
|
||||||
let addHistory requestId : HttpHandler =
|
let addHistory requestId : HttpHandler =
|
||||||
authorize
|
authorize
|
||||||
|
>=> allowSyncIO
|
||||||
>=> fun next ctx ->
|
>=> fun next ctx ->
|
||||||
task {
|
task {
|
||||||
use sess = session ctx
|
use sess = session ctx
|
||||||
@@ -218,6 +229,7 @@ module Request =
|
|||||||
/// POST /api/request/[req-id]/note
|
/// POST /api/request/[req-id]/note
|
||||||
let addNote requestId : HttpHandler =
|
let addNote requestId : HttpHandler =
|
||||||
authorize
|
authorize
|
||||||
|
>=> allowSyncIO
|
||||||
>=> fun next ctx ->
|
>=> fun next ctx ->
|
||||||
task {
|
task {
|
||||||
use sess = session ctx
|
use sess = session ctx
|
||||||
@@ -297,6 +309,7 @@ module Request =
|
|||||||
/// PATCH /api/request/[req-id]/snooze
|
/// PATCH /api/request/[req-id]/snooze
|
||||||
let snooze requestId : HttpHandler =
|
let snooze requestId : HttpHandler =
|
||||||
authorize
|
authorize
|
||||||
|
>=> allowSyncIO
|
||||||
>=> fun next ctx ->
|
>=> fun next ctx ->
|
||||||
task {
|
task {
|
||||||
use sess = session ctx
|
use sess = session ctx
|
||||||
@@ -314,6 +327,7 @@ module Request =
|
|||||||
/// PATCH /api/request/[req-id]/recurrence
|
/// PATCH /api/request/[req-id]/recurrence
|
||||||
let updateRecurrence requestId : HttpHandler =
|
let updateRecurrence requestId : HttpHandler =
|
||||||
authorize
|
authorize
|
||||||
|
>=> allowSyncIO
|
||||||
>=> fun next ctx ->
|
>=> fun next ctx ->
|
||||||
task {
|
task {
|
||||||
use sess = session ctx
|
use sess = session ctx
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<Version>2.0.0.0</Version>
|
<Version>2.2.0.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -14,19 +14,15 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FunctionalCuid" Version="1.0.0" />
|
<PackageReference Include="FunctionalCuid" Version="1.0.0" />
|
||||||
<PackageReference Include="Giraffe" Version="3.6.0" />
|
<PackageReference Include="Giraffe" Version="4.1.0" />
|
||||||
<PackageReference Include="Giraffe.TokenRouter" Version="1.0.0" />
|
<PackageReference Include="Giraffe.TokenRouter" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
|
||||||
<PackageReference Include="Microsoft.FSharpLu" Version="0.10.29" />
|
<PackageReference Include="Microsoft.FSharpLu" Version="0.11.6" />
|
||||||
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.10.29" />
|
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.6" />
|
||||||
<PackageReference Include="RavenDb.Client" Version="4.2.1" />
|
<PackageReference Include="RavenDb.Client" Version="4.2.102" />
|
||||||
<PackageReference Include="TaskBuilder.fs" Version="2.1.0" />
|
<PackageReference Include="TaskBuilder.fs" Version="2.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Update="FSharp.Core" Version="4.7.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="wwwroot\" />
|
<Folder Include="wwwroot\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -90,11 +90,12 @@ module Configure =
|
|||||||
bldr.ConfigureServices svcs
|
bldr.ConfigureServices svcs
|
||||||
|
|
||||||
open Microsoft.Extensions.Logging
|
open Microsoft.Extensions.Logging
|
||||||
|
open Microsoft.Extensions.Hosting
|
||||||
|
|
||||||
/// Configure logging
|
/// Configure logging
|
||||||
let logging (bldr : IWebHostBuilder) =
|
let logging (bldr : IWebHostBuilder) =
|
||||||
let logz (log : ILoggingBuilder) =
|
let logz (log : ILoggingBuilder) =
|
||||||
let env = log.Services.BuildServiceProvider().GetService<IHostingEnvironment> ()
|
let env = log.Services.BuildServiceProvider().GetService<IWebHostEnvironment> ()
|
||||||
match env.IsDevelopment () with
|
match env.IsDevelopment () with
|
||||||
| true -> log
|
| true -> log
|
||||||
| false -> log.AddFilter(fun l -> l > LogLevel.Information)
|
| false -> log.AddFilter(fun l -> l > LogLevel.Information)
|
||||||
@@ -109,7 +110,7 @@ module Configure =
|
|||||||
let appConfig =
|
let appConfig =
|
||||||
Action<IApplicationBuilder> (
|
Action<IApplicationBuilder> (
|
||||||
fun (app : IApplicationBuilder) ->
|
fun (app : IApplicationBuilder) ->
|
||||||
let env = app.ApplicationServices.GetService<IHostingEnvironment> ()
|
let env = app.ApplicationServices.GetService<IWebHostEnvironment> ()
|
||||||
match env.IsDevelopment () with
|
match env.IsDevelopment () with
|
||||||
| true -> app.UseDeveloperExceptionPage ()
|
| true -> app.UseDeveloperExceptionPage ()
|
||||||
| false -> app.UseGiraffeErrorHandler Handlers.Error.error
|
| false -> app.UseGiraffeErrorHandler Handlers.Error.error
|
||||||
|
|||||||
2
src/app/.gitignore
vendored
2
src/app/.gitignore
vendored
@@ -21,4 +21,4 @@ yarn-error.log*
|
|||||||
*.sw*
|
*.sw*
|
||||||
|
|
||||||
# Auth0 settings
|
# Auth0 settings
|
||||||
src/auth/auth0-variables.js
|
src/auth/auth0-variables.*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-prayer-journal",
|
"name": "my-prayer-journal",
|
||||||
"version": "2.0.0",
|
"version": "2.2.0",
|
||||||
"description": "myPrayerJournal - Front End",
|
"description": "myPrayerJournal - Front End",
|
||||||
"author": "Daniel J. Summers <daniel@bitbadger.solutions>",
|
"author": "Daniel J. Summers <daniel@bitbadger.solutions>",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
"lint": "vue-cli-service lint",
|
"lint": "vue-cli-service lint",
|
||||||
"apistart": "cd ../MyPrayerJournal.Api && dotnet run",
|
"apistart": "cd ../MyPrayerJournal.Api && dotnet run",
|
||||||
"vue": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet run",
|
"vue": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet run",
|
||||||
"publish": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet publish -c Release"
|
"publish": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet publish -c Release -r linux-x64 --self-contained false"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"auth0-js": "^9.7.3",
|
"auth0-js": "^9.13.2",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.21.1",
|
||||||
"moment": "^2.18.1",
|
"moment": "^2.18.1",
|
||||||
"vue": "^2.5.15",
|
"vue": "^2.5.15",
|
||||||
"vue-material": "^1.0.0-beta-11",
|
"vue-material": "^1.0.0-beta-13",
|
||||||
"vue-router": "^3.0.0",
|
"vue-router": "^3.0.0",
|
||||||
"vuex": "^3.0.1"
|
"vuex": "^3.0.1"
|
||||||
},
|
},
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"@vue/cli-service": "^3.0.0",
|
"@vue/cli-service": "^3.0.0",
|
||||||
"@vue/eslint-config-standard": "^4.0.0",
|
"@vue/eslint-config-standard": "^4.0.0",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
"pug": "^2.0.1",
|
"pug": "^3.0.1",
|
||||||
"pug-plain-loader": "^1.0.0",
|
"pug-plain-loader": "^1.0.0",
|
||||||
"sass-loader": "^7.3.1",
|
"sass-loader": "^7.3.1",
|
||||||
"vue-template-compiler": "^2.5.17",
|
"vue-template-compiler": "^2.5.17",
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#app.page-container
|
#app.page-container
|
||||||
md-app(md-waterfall md-mode='fixed-last' role='application')
|
md-app(md-waterfall md-mode='fixed-last' role='application')
|
||||||
md-app-toolbar.md-large.md-dense.md-primary
|
md-app-toolbar.md-large.md-dense.md-primary
|
||||||
|
md-progress-bar(v-if='progress.visible'
|
||||||
|
:md-mode='progress.mode')
|
||||||
|
.md-no-progress-bar(v-if='!progress.visible')
|
||||||
.md-toolbar-row
|
.md-toolbar-row
|
||||||
.md-toolbar-section-start
|
.md-toolbar-section-start
|
||||||
router-link(to='/').md-title
|
router-link(to='/').md-title
|
||||||
@@ -10,8 +13,6 @@
|
|||||||
span(style='font-weight:700;') Journal
|
span(style='font-weight:700;') Journal
|
||||||
navigation
|
navigation
|
||||||
md-app-content
|
md-app-content
|
||||||
md-progress-bar(v-if='progress.visible'
|
|
||||||
:md-mode='progress.mode')
|
|
||||||
router-view
|
router-view
|
||||||
md-snackbar(:md-active.sync='snackbar.visible'
|
md-snackbar(:md-active.sync='snackbar.visible'
|
||||||
md-position='center'
|
md-position='center'
|
||||||
@@ -153,6 +154,12 @@ p.mpj-request-text
|
|||||||
margin: auto
|
margin: auto
|
||||||
.mpj-full-width
|
.mpj-full-width
|
||||||
width: 100%
|
width: 100%
|
||||||
.md-progress-bar
|
.md-toolbar > .md-progress-bar
|
||||||
margin: 24px
|
height: 2px
|
||||||
|
width: 100%
|
||||||
|
background-color: rgba(255, 255, 255, .8) !important
|
||||||
|
margin: 0
|
||||||
|
.md-toolbar > .md-no-progress-bar
|
||||||
|
height: 2px
|
||||||
|
width: 100%
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ md-dialog(:md-active.sync='notesVisible').mpj-note-dialog
|
|||||||
md-dialog-actions
|
md-dialog-actions
|
||||||
md-button(@click='saveNotes()').md-primary #[md-icon save] Save
|
md-button(@click='saveNotes()').md-primary #[md-icon save] Save
|
||||||
md-button(@click='closeDialog()') #[md-icon undo] Cancel
|
md-button(@click='closeDialog()') #[md-icon undo] Cancel
|
||||||
.mpj-dialog-content
|
md-dialog-content(md-scrollbar='true').mpj-dialog-content
|
||||||
div(v-if='hasPriorNotes')
|
div(v-if='hasPriorNotes')
|
||||||
p.mpj-text-center: strong Prior Notes for This Request
|
p.mpj-text-center: strong Prior Notes for This Request
|
||||||
.mpj-note-list
|
.mpj-note-list
|
||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
this.progress.$emit('show', 'indeterminate')
|
this.progress.$emit('show', 'indeterminate')
|
||||||
try {
|
try {
|
||||||
const notes = await api.getNotes(this.form.requestId)
|
const notes = await api.getNotes(this.form.requestId)
|
||||||
this.priorNotes = notes.data
|
this.priorNotes = notes.data.sort((a, b) => b.asOf - a.asOf)
|
||||||
this.progress.$emit('done')
|
this.progress.$emit('done')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|||||||
@@ -50,11 +50,22 @@ const setBearer = async function () {
|
|||||||
}
|
}
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sort value for a prayer request
|
||||||
|
* @param x The prayer request
|
||||||
|
*/
|
||||||
|
const sortValue = x => x.showAfter === 0 ? x.asOf : x.showAfter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort journal requests either by asOf or showAfter
|
||||||
|
*/
|
||||||
|
const journalSort = (a, b) => sortValue(a) - sortValue(b)
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
user: auth.session.profile,
|
user: auth.session.profile,
|
||||||
isAuthenticated: auth.isAuthenticated(),
|
isAuthenticated: auth.isAuthenticated(),
|
||||||
journal: {},
|
journal: [],
|
||||||
isLoadingJournal: false
|
isLoadingJournal: false
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -62,7 +73,7 @@ export default new Vuex.Store({
|
|||||||
state.isLoadingJournal = flag
|
state.isLoadingJournal = flag
|
||||||
},
|
},
|
||||||
[mutations.LOADED_JOURNAL] (state, journal) {
|
[mutations.LOADED_JOURNAL] (state, journal) {
|
||||||
state.journal = journal
|
state.journal = journal.sort(journalSort)
|
||||||
},
|
},
|
||||||
[mutations.REQUEST_ADDED] (state, newRequest) {
|
[mutations.REQUEST_ADDED] (state, newRequest) {
|
||||||
state.journal.push(newRequest)
|
state.journal.push(newRequest)
|
||||||
@@ -107,7 +118,7 @@ export default new Vuex.Store({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async [actions.LOAD_JOURNAL] ({ commit }, progress) {
|
async [actions.LOAD_JOURNAL] ({ commit }, progress) {
|
||||||
commit(mutations.LOADED_JOURNAL, {})
|
commit(mutations.LOADED_JOURNAL, [])
|
||||||
progress.$emit('show', 'query')
|
progress.$emit('show', 'query')
|
||||||
commit(mutations.LOADING_JOURNAL, true)
|
commit(mutations.LOADING_JOURNAL, true)
|
||||||
await setBearer()
|
await setBearer()
|
||||||
|
|||||||
5428
src/app/yarn.lock
5428
src/app/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,110 +0,0 @@
|
|||||||
|
|
||||||
open Microsoft.FSharpLu.Json
|
|
||||||
open MyPrayerJournal
|
|
||||||
open Npgsql
|
|
||||||
open Raven.Client.Documents
|
|
||||||
|
|
||||||
type NpgsqlDataReader with
|
|
||||||
member this.getShort = this.GetOrdinal >> this.GetInt16
|
|
||||||
member this.getString = this.GetOrdinal >> this.GetString
|
|
||||||
member this.getTicks = this.GetOrdinal >> this.GetInt64 >> Ticks
|
|
||||||
member this.isNull = this.GetOrdinal >> this.IsDBNull
|
|
||||||
|
|
||||||
let pgConn connStr =
|
|
||||||
let c = new NpgsqlConnection (connStr)
|
|
||||||
c.Open ()
|
|
||||||
c
|
|
||||||
|
|
||||||
let isValidStatus stat =
|
|
||||||
try
|
|
||||||
(RequestAction.fromString >> ignore) stat
|
|
||||||
true
|
|
||||||
with _ -> false
|
|
||||||
|
|
||||||
let getHistory reqId connStr =
|
|
||||||
use conn = pgConn connStr
|
|
||||||
use cmd = conn.CreateCommand ()
|
|
||||||
cmd.CommandText <- """SELECT "asOf", status, text FROM mpj.history WHERE "requestId" = @reqId ORDER BY "asOf" """
|
|
||||||
(cmd.Parameters.Add >> ignore) (NpgsqlParameter ("@reqId", reqId :> obj))
|
|
||||||
use rdr = cmd.ExecuteReader ()
|
|
||||||
seq {
|
|
||||||
while rdr.Read () do
|
|
||||||
match (rdr.getString >> isValidStatus) "status" with
|
|
||||||
| true ->
|
|
||||||
yield
|
|
||||||
{ asOf = rdr.getTicks "asOf"
|
|
||||||
status = (rdr.getString >> RequestAction.fromString) "status"
|
|
||||||
text = match rdr.isNull "text" with true -> None | false -> (rdr.getString >> Some) "text"
|
|
||||||
}
|
|
||||||
| false ->
|
|
||||||
printf "Invalid status %s; skipped history entry %s/%i\n" (rdr.getString "status") reqId
|
|
||||||
((rdr.getTicks >> Ticks.toLong) "asOf")
|
|
||||||
}
|
|
||||||
|> List.ofSeq
|
|
||||||
|
|
||||||
let getNotes reqId connStr =
|
|
||||||
use conn = pgConn connStr
|
|
||||||
use cmd = conn.CreateCommand ()
|
|
||||||
cmd.CommandText <- """SELECT "asOf", notes FROM mpj.note WHERE "requestId" = @reqId"""
|
|
||||||
(cmd.Parameters.Add >> ignore) (NpgsqlParameter ("@reqId", reqId :> obj))
|
|
||||||
use rdr = cmd.ExecuteReader ()
|
|
||||||
seq {
|
|
||||||
while rdr.Read () do
|
|
||||||
yield
|
|
||||||
{ asOf = rdr.getTicks "asOf"
|
|
||||||
notes = rdr.getString "notes"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|> List.ofSeq
|
|
||||||
|
|
||||||
let migrateRequests (store : IDocumentStore) connStr =
|
|
||||||
use sess = store.OpenSession ()
|
|
||||||
use conn = pgConn connStr
|
|
||||||
use cmd = conn.CreateCommand ()
|
|
||||||
cmd.CommandText <-
|
|
||||||
"""SELECT "requestId", "enteredOn", "userId", "snoozedUntil", "showAfter", "recurType", "recurCount" FROM mpj.request"""
|
|
||||||
use rdr = cmd.ExecuteReader ()
|
|
||||||
while rdr.Read () do
|
|
||||||
let reqId = rdr.getString "requestId"
|
|
||||||
let recurrence =
|
|
||||||
match rdr.getString "recurType" with
|
|
||||||
| "immediate" -> Immediate
|
|
||||||
| "hours" -> Hours
|
|
||||||
| "days" -> Days
|
|
||||||
| "weeks" -> Weeks
|
|
||||||
| x -> invalidOp (sprintf "%s is not a valid recurrence" x)
|
|
||||||
sess.Store (
|
|
||||||
{ Id = (RequestId.fromIdString >> RequestId.toString) reqId
|
|
||||||
enteredOn = rdr.getTicks "enteredOn"
|
|
||||||
userId = (rdr.getString >> UserId) "userId"
|
|
||||||
snoozedUntil = rdr.getTicks "snoozedUntil"
|
|
||||||
showAfter = match recurrence with Immediate -> Ticks 0L | _ -> rdr.getTicks "showAfter"
|
|
||||||
recurType = recurrence
|
|
||||||
recurCount = rdr.getShort "recurCount"
|
|
||||||
history = getHistory reqId connStr
|
|
||||||
notes = getNotes reqId connStr
|
|
||||||
})
|
|
||||||
sess.SaveChanges ()
|
|
||||||
|
|
||||||
open Converters
|
|
||||||
open System
|
|
||||||
open System.Security.Cryptography.X509Certificates
|
|
||||||
|
|
||||||
[<EntryPoint>]
|
|
||||||
let main argv =
|
|
||||||
match argv.Length with
|
|
||||||
| 4 ->
|
|
||||||
let clientCert = new X509Certificate2 (argv.[1], argv.[2])
|
|
||||||
let raven = new DocumentStore (Urls = [| argv.[0] |], Database = "myPrayerJournal", Certificate = clientCert)
|
|
||||||
raven.Conventions.CustomizeJsonSerializer <-
|
|
||||||
fun x ->
|
|
||||||
x.Converters.Add (RequestIdJsonConverter ())
|
|
||||||
x.Converters.Add (TicksJsonConverter ())
|
|
||||||
x.Converters.Add (UserIdJsonConverter ())
|
|
||||||
x.Converters.Add (CompactUnionJsonConverter ())
|
|
||||||
let store = raven.Initialize ()
|
|
||||||
migrateRequests store argv.[3]
|
|
||||||
printfn "fin"
|
|
||||||
| _ ->
|
|
||||||
Console.WriteLine "Usage: dotnet migrate.dll [raven-url] [raven-cert-file] [raven-cert-pw] [postgres-conn-str]"
|
|
||||||
0
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Program.fs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.2" />
|
|
||||||
<PackageReference Include="Npgsql" Version="4.0.8" />
|
|
||||||
<PackageReference Include="RavenDb.Client" Version="4.2.2" />
|
|
||||||
<ProjectReference Include="../MyPrayerJournal.Api/MyPrayerJournal.Api.fsproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Update="FSharp.Core" Version="4.7.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
Reference in New Issue
Block a user