Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac8b39fff9 | ||
|
|
2bf54136ca | ||
|
|
0709cabea1 | ||
|
|
cbd9114599 | ||
|
|
097ee2deb4 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>2.0.0.0</Version>
|
<Version>2.0.1.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
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.0.1",
|
||||||
"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,
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
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