Skip to content

Commit

Permalink
Lisätty viestin sisältö muistutus tapahtumaan ja lähetyskellon aika t…
Browse files Browse the repository at this point in the history
…äydennyspyynnön tietoihin
  • Loading branch information
hajoa committed Jan 22, 2025
1 parent 5681df2 commit b1de565
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 23 deletions.
3 changes: 2 additions & 1 deletion config/cypress.ci.edn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
:attachment-file-max-size-bytes 10485760
:attachment-file-part-max-size-bytes 5242880
:features {:arvosanat true
:hakeminen-tunnistautuneena false}}
:hakeminen-tunnistautuneena false}
:information-request-reminder-job-hour 9}
:temp-files {:filesystem {:base-path "/tmp"}}
:dev {:fake-dependencies true}
:urls {:virkailija-host "toimimaton.virkailija-host-arvo.cypress.ci.edn-tiedostosta"
Expand Down
3 changes: 2 additions & 1 deletion config/cypress.edn
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
:attachment-file-max-size-bytes 10485760
:attachment-file-part-max-size-bytes 5242880
:features {:schema-validation true
:arvosanat true}}
:arvosanat true}
:information-request-reminder-job-hour 9}
:temp-files {:filesystem {:base-path "/tmp"}}
:dev {:fake-dependencies true}
:urls {:virkailija-host "toimimaton.virkailija-host-arvo.cypress.edn-tiedostosta"
Expand Down
3 changes: 2 additions & 1 deletion config/defaults.edn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
:tutu-default-processing-fee "100.00"
:attachment-modify-grace-period-days 14
:attachment-file-max-size-bytes 10485760
:attachment-file-part-max-size-bytes 5242880}
:attachment-file-part-max-size-bytes 5242880
:information-request-reminder-job-hour 9}
:temp-files {:filesystem {:base-path "/tmp"}}
:background-job {:exec-interval-seconds 15}
:log {:virkailija-base-path "/tmp"
Expand Down
3 changes: 2 additions & 1 deletion config/dev.edn
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
:job-failure-alert-recipients "testi@example.org"
:send-job-failure-alert-emails true
:features {:schema-validation true
:hakeminen-tunnistautuneena true}}
:hakeminen-tunnistautuneena true}
:information-request-reminder-job-hour 9}
:temp-files {:filesystem {:base-path "/tmp"}}
:dev {:fake-dependencies true}
:urls {:virkailija-host "toimimaton.virkailija-host-arvo.dev.edn-tiedostosta"
Expand Down
3 changes: 2 additions & 1 deletion config/test.edn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
:attachment-file-part-max-size-bytes 5242880
:job-failure-alert-recipients "testi@example.org"
:send-job-failure-alert-emails true
:features {:schema-validation true}}
:features {:schema-validation true}
:information-request-reminder-job-hour 9}
:temp-files {:filesystem {:base-path "/tmp"}}
:dev {:fake-dependencies true}
:urls {:virkailija-host "toimimaton.virkailija-host-arvo.test.edn-tiedostosta"
Expand Down
6 changes: 3 additions & 3 deletions oph-configuration/config.edn.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
:kouta-hakus-by-form-key {{ataru_cache_ttl_amounts_kouta_hakus_by_form_key | default('3')}}
:hakukohde-search {{ataru_cache_ttl_amounts_hakukohde_search | default('3')}}}}
:redis {:uri "{{ataru_redis_uri}}"}
:jobs {:application-payment-module-cron "{{ataru_jobs_application_payment_module_cron | default('0 4 * * *')}}"
:information-request-reminder-job-cron "{{ataru_jobs_information_request_reminder_job_cron | default('0 9,16 * * *')}}"}
:jobs {:application-payment-module-cron "{{ataru_jobs_application_payment_module_cron | default('0 4 * * *')}}"}
:aws {:region "{{aws_region}}"
:liiteri-files {:bucket "{{liiteri_s3_bucket}}"}
:feedback-queue {:queue-url "{{palaute_queue_url}}"}
Expand Down Expand Up @@ -68,7 +67,8 @@
:attachment-preview-pages-to-display {{liiteri_attachment_preview_pages_to_display}}
:job-failure-alert-recipients "{{ataru_job_failure_alert_recipients}}"
:send-job-failure-alert-emails {{ataru_send_job_failure_alert_emails | default('true')}}
:tutu-default-processing-fee "{{ataru_tutkintojen_tunnustaminen_maksut_decision_amount | default('100.00')}}"}
:tutu-default-processing-fee "{{ataru_tutkintojen_tunnustaminen_maksut_decision_amount | default('100.00')}}"
:information-request-reminder-job-hour {{ataru_jobs_information_request_reminder_job_hour | default('9')}}}
:cas {:username "{{ataru_cas_username}}"
:password "{{ataru_cas_password}}"}
:log {:virkailija-base-path "{{ataru_virkailija_log_path}}"
Expand Down
3 changes: 2 additions & 1 deletion resources/sql/information-request-queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ INSERT INTO information_requests (
-- name: yesql-get-information-requests
-- Get all information requests belonging to an application
SELECT
ir.id,
ir.application_key,
ir.subject,
ir.message,
Expand All @@ -47,7 +48,7 @@ SELECT
FROM information_requests ir
LEFT JOIN latest_applications a ON ir.application_key = a.key
WHERE ir.reminder_processed_time IS NULL
AND ir.send_reminder_time <= now();
AND ir.send_reminder_time::date <= current_date;

-- name: yesql-set-information-request-reminder-processed-time-by-id!
-- Set reminder-processed-time to now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
(application-store/add-application-event-in-tx
connection
{:application-key (:application-key information-request)
:event-type "information-request-reminder-sent"}
:event-type "information-request-reminder-sent"
:review-key (str (:id information-request))}
nil)
(ir-store/set-information-request-reminder-processed-time-by-id-in-tx! connection (:id information-request)))))

Expand All @@ -33,6 +34,8 @@
(doseq [information-request information-requests]
(handle-reminder information-request job-runner))))

(def job-cron (str "0 " (get-in config [:public-config :information-request-reminder-job-hour]) " * * *"))

(def job-definition {:handler handler
:type (-> *ns* ns-name str)
:schedule (get-in config [:jobs :information-request-reminder-job-cron])})
:schedule job-cron})
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
[ataru.information-request.information-request-store :as information-request-store]
[ataru.tutkintojen-tunnustaminen :as tutkintojen-tunnustaminen]
[ataru.applications.application-store :as app-store]
[ataru.config.core :refer [config]]
[clojure.java.jdbc :as jdbc]
[selmer.parser :as selmer]
[clojure.string :as string]
[ataru.background-job.job :as job]
[taoensso.timbre :as log]
[clj-time.core :as time]))
[clj-time.core :as time])
(:import (org.joda.time DateTime)))

(defn- information-request-email-template-filename
[lang]
Expand Down Expand Up @@ -106,7 +108,12 @@
(-> information-request :message-type u/not-blank?)]}
(let [add-update-link (:add-update-link information-request)
send-reminder-time (when (:send-reminder? information-request)
(time/plus (time/today-at 6 0) (time/days (:reminder-days information-request))))
(time/plus
(-> (new DateTime)
(.withTime
(get-in config [:public-config :information-request-reminder-job-hour])
0 0 0))
(time/days (:reminder-days information-request))))
information-request (information-request-store/add-information-request
(assoc
information-request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(->snake-case-kw)
(yesql-add-information-request<! {:connection conn})
(->kebab-case-kw)
(dissoc :virkailija-oid :id)))
(dissoc :virkailija-oid)))

(defn get-information-requests [application-key]
(->> (exec-db :db yesql-get-information-requests {:application_key application-key})
Expand Down
3 changes: 2 additions & 1 deletion src/cljc/ataru/schema/form_schema.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@
(and (not send-reminder?) (nil? reminder-days))))
'reminder-days-only-when-send-reminder-true))

(s/defschema InformationRequest {:subject s/Str
(s/defschema InformationRequest {:id s/Num
:subject s/Str
(s/optional-key :recipient-target) s/Str
:message s/Str
:application-key s/Str
Expand Down
9 changes: 6 additions & 3 deletions src/cljc/ataru/translations/texts.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,9 @@
:information-request-reminder-sent {:fi "Täydennyspyynnön muistutusviesti lähetetty"
:en "EN Täydennyspyynnön muistutusviesti lähetetty"
:sv "SV Täydennyspyynnön muistutusviesti lähetetty"}
:information-request-reminder-subject-prefix {:fi "Muistutus"
:en "Reminder"
:sv "Påminnelse"}
:single-information-request-sent {:fi "Viesti lähetetty"
:sv "Meddelandet har skickats"
:en "Message has been sent"}
Expand Down Expand Up @@ -2171,9 +2174,9 @@
:information-request-reminder-will-be-sent {:fi "Muistutusviesti lähetetään"
:sv "SV Muistutusviesti lähetetään"
:en "EN Muistutusviesti lähetetään"}
:information-request-reminder-after {:fi "päivän kuluttua"
:sv "SV päivän kuluttua"
:en "EN päivän kuluttua"}
:information-request-reminder-after {:fi "päivän kuluttua klo"
:sv "SV päivän kuluttua klo"
:en "EN päivän kuluttua klo"}
:set-haku-to-form {:fi "Aseta ensin lomake haun käyttöön niin voit tehdä hakukohteen mukaan näkyviä sisältöjä."
:sv "Ställ först blanketten för användning i ansökan för att kunna bilda innehåll för ansökningsmålet."
:en "EN: Aseta ensin lomake haun käyttöön niin voit tehdä hakukohteen mukaan näkyviä sisältöjä."}
Expand Down
22 changes: 17 additions & 5 deletions src/cljs/ataru/virkailija/application/application_review_view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [ataru.application.application-states :as application-states]
[ataru.application.review-states :as review-states]
[ataru.cljs-util :as cljs-util]
[ataru.config :as config]
[ataru.util :as util]
[ataru.virkailija.application.application-subs]
[ataru.virkailija.application.application-authorization-subs]
Expand Down Expand Up @@ -583,16 +584,24 @@
[:span.application-handling__event-row--message-subject
@(subscribe [:editor/virkailija-translation :information-request-reminder-will-be-sent])
": "
(temporal/time->date (:send-reminder-time event))])
(temporal/time->short-str (:send-reminder-time event))])
[:span.application-handling__event-row--message-subject
(:subject event)]
[:span.application-handling__event-row--message-body
(:message event)]]]

{:event-type "information-request-reminder-sent"}
[[:span
@(subscribe [:editor/virkailija-translation :information-request-reminder-sent])]
nil]
(let [ir (some #(when (= (:review-key event) (str (:id %))) %) @(subscribe [:state-query [:application :information-requests]]))]
[[:span
@(subscribe [:editor/virkailija-translation :information-request-reminder-sent])]
(when (some? ir)
[:div.application-handling__event-row--message
[:span.application-handling__event-row--message-subject
@(subscribe [:editor/virkailija-translation :information-request-reminder-subject-prefix])
": "
(:subject ir)]
[:span.application-handling__event-row--message-body
(:message ir)]])])

:else
[[:span @(subscribe [:editor/virkailija-translation :unknown])]
Expand Down Expand Up @@ -829,7 +838,10 @@
(map
#(list [:option {:value %} %])
days-options)]
[:p @(subscribe [:editor/virkailija-translation :information-request-reminder-after])]]]))
[:p @(subscribe [:editor/virkailija-translation :information-request-reminder-after])
" "
(config/get-public-config [:information-request-reminder-job-hour])
":00"]]]))

(defn- application-information-request-send-reminder []
(let [send-reminder? @(subscribe [:application/information-request-send-reminder])]
Expand Down

0 comments on commit b1de565

Please sign in to comment.