myPrayerJournal v2 #27

Merged
danieljsummers merged 27 commits from version-2 into master 2019-09-03 00:01:26 +00:00
6 changed files with 25 additions and 23 deletions
Showing only changes of commit 0ea4249b65 - Show all commits

View File

@ -126,13 +126,6 @@ module Models =
recurCount : int16 recurCount : int16
} }
/// Reset the "showAfter" property on a request
[<CLIMutable>]
type Show =
{ /// The time after which the request should appear
showAfter : int64
}
/// The time until which a request should not appear in the journal /// The time until which a request should not appear in the journal
[<CLIMutable>] [<CLIMutable>]
type SnoozeUntil = type SnoozeUntil =
@ -175,7 +168,7 @@ module Request =
Id = RequestId.toString reqId Id = RequestId.toString reqId
userId = usrId userId = usrId
enteredOn = now enteredOn = now
showAfter = now showAfter = Ticks 0L
recurType = Recurrence.fromString r.recurType recurType = Recurrence.fromString r.recurType
recurCount = r.recurCount recurCount = r.recurCount
history = [ history = [
@ -211,7 +204,10 @@ module Request =
} sess } sess
match act with match act with
| Prayed -> | Prayed ->
let nextShow = (Ticks.toLong now) + (Recurrence.duration req.recurType * int64 req.recurCount) let nextShow =
match Recurrence.duration req.recurType with
| 0L -> 0L
| duration -> (Ticks.toLong now) + (duration * int64 req.recurCount)
Data.updateShowAfter reqId (Ticks nextShow) sess Data.updateShowAfter reqId (Ticks nextShow) sess
| _ -> () | _ -> ()
do! Data.saveChanges sess do! Data.saveChanges sess
@ -292,8 +288,7 @@ module Request =
let reqId = toReqId requestId let reqId = toReqId requestId
match! Data.tryRequestById reqId usrId sess with match! Data.tryRequestById reqId usrId sess with
| Some _ -> | Some _ ->
let! show = ctx.BindJsonAsync<Models.Show> () Data.updateShowAfter reqId (Ticks 0L) sess
Data.updateShowAfter reqId (Ticks show.showAfter) sess
do! Data.saveChanges sess do! Data.saveChanges sess
return! setStatusCode 204 next ctx return! setStatusCode 204 next ctx
| None -> return! Error.notFound next ctx | None -> return! Error.notFound next ctx
@ -327,7 +322,9 @@ module Request =
match! Data.tryRequestById reqId usrId sess with match! Data.tryRequestById reqId usrId sess with
| Some _ -> | Some _ ->
let! recur = ctx.BindJsonAsync<Models.Recurrence> () let! recur = ctx.BindJsonAsync<Models.Recurrence> ()
Data.updateRecurrence reqId (Recurrence.fromString recur.recurType) recur.recurCount sess let recurrence = Recurrence.fromString recur.recurType
Data.updateRecurrence reqId recurrence recur.recurCount sess
match recurrence with Immediate -> Data.updateShowAfter reqId (Ticks 0L) sess | _ -> ()
do! Data.saveChanges sess do! Data.saveChanges sess
return! setStatusCode 204 next ctx return! setStatusCode 204 next ctx
| None -> return! Error.notFound next ctx | None -> return! Error.notFound next ctx

View File

@ -76,7 +76,7 @@ export default {
await this.$store.dispatch(actions.SHOW_REQUEST_NOW, { await this.$store.dispatch(actions.SHOW_REQUEST_NOW, {
progress: this.progress, progress: this.progress,
requestId: this.request.requestId, requestId: this.request.requestId,
showAfter: Date.now() showAfter: 0
}) })
this.messages.$emit('info', 'Recurrence skipped; request now shows in journal') this.messages.$emit('info', 'Recurrence skipped; request now shows in journal')
this.$parent.$emit('requestNowShown') this.$parent.$emit('requestNowShown')

View File

@ -1,6 +1,6 @@
'use strict' 'use strict'
/* eslint-disable */ /* eslint-disable no-multi-spaces */
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
@ -9,10 +9,11 @@ import auth from '@/auth/AuthService'
import mutations from './mutation-types' import mutations from './mutation-types'
import actions from './action-types' import actions from './action-types'
/* eslint-enable */ /* eslint-enable no-multi-spaces */
Vue.use(Vuex) Vue.use(Vuex)
/* eslint-disable no-console */
const logError = function (error) { const logError = function (error) {
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code // The request was made and the server responded with a status code
@ -47,6 +48,7 @@ const setBearer = async function () {
} }
} }
} }
/* eslint-enable no-console */
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {

View File

@ -66,19 +66,22 @@ let migrateRequests (store : IDocumentStore) =
use rdr = cmd.ExecuteReader () use rdr = cmd.ExecuteReader ()
while rdr.Read () do while rdr.Read () do
let reqId = rdr.getString "requestId" let reqId = rdr.getString "requestId"
let recurrence = (rdr.getString >> Recurrence.fromString) "recurType"
sess.Store ( sess.Store (
{ Id = (RequestId.fromIdString >> RequestId.toString) reqId { Id = (RequestId.fromIdString >> RequestId.toString) reqId
enteredOn = rdr.getTicks "enteredOn" enteredOn = rdr.getTicks "enteredOn"
userId = (rdr.getString >> UserId) "userId" userId = (rdr.getString >> UserId) "userId"
snoozedUntil = rdr.getTicks "snoozedUntil" snoozedUntil = rdr.getTicks "snoozedUntil"
showAfter = rdr.getTicks "showAfter" showAfter = match recurrence with Immediate -> Ticks 0L | _ -> rdr.getTicks "showAfter"
recurType = (rdr.getString >> Recurrence.fromString) "recurType" recurType = recurrence
recurCount = rdr.getShort "recurCount" recurCount = rdr.getShort "recurCount"
history = getHistory reqId history = getHistory reqId
notes = getNotes reqId notes = getNotes reqId
}) })
sess.SaveChanges () sess.SaveChanges ()
open Converters
[<EntryPoint>] [<EntryPoint>]
let main argv = let main argv =
let raven = new DocumentStore (Urls = [| "http://localhost:8080" |], Database = "myPrayerJournal") let raven = new DocumentStore (Urls = [| "http://localhost:8080" |], Database = "myPrayerJournal")

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.6.2" /> <PackageReference Include="FSharp.Core" Version="4.7.0" />
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.2" /> <PackageReference Include="Microsoft.FSharpLu.Json" Version="0.11.2" />
<PackageReference Include="Npgsql" Version="4.0.8" /> <PackageReference Include="Npgsql" Version="4.0.8" />
<PackageReference Include="RavenDb.Client" Version="4.2.2" /> <PackageReference Include="RavenDb.Client" Version="4.2.2" />