Skip to content

Commit

Permalink
EH-1757: make aloitusheräte resends consistent with päättöheräte resends
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalliok committed Jan 10, 2025
1 parent 2b4bffa commit d2afcbc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT * FROM hoksit h
WHERE h.created_at >= ? -- FIXME: is this correct, what about updated_at?
AND h.created_at <= ?
WHERE h.ensikertainen_hyvaksyminen >= ?
AND h.ensikertainen_hyvaksyminen <= ?
AND h.deleted_at IS NULL
AND h.tuva_opiskeluoikeus_oid IS NULL
AND NOT EXISTS (SELECT 1 FROM hankittavat_koulutuksen_osat hko
Expand Down
12 changes: 6 additions & 6 deletions src/oph/ehoks/db/db_operations/hoks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,17 @@
[queries/select-hoksit-finished-between from to]
{:row-fn hoks-from-sql}))

(defn select-non-tuva-hoksit-created-between
"Hakee tietokannasta ne HOKSit, jotka on luotu annettujen ajankohtien
välillä ja jotka eivät ole TUVA-HOKSeja tai TUVA-HOKSien kanssa
rinnakkaisia ammatillisia HOKSeja."
(defn select-non-tuva-hoksit-started-between
"Hakee tietokannasta ne HOKSit, jotka on merkitty alkaneiksi annettujen
ajankohtien välillä ja jotka eivät ole TUVA-HOKSeja tai TUVA-HOKSien
kanssa rinnakkaisia ammatillisia HOKSeja."
[from to]
(db-ops/query
[queries/select-non-tuva-hoksit-created-between from to]
[queries/select-non-tuva-hoksit-started-between from to]
{:row-fn hoks-from-sql}))

(defn select-non-tuva-hoksit-finished-between
"Hakee tietokannasta ne HOKSit, jotka on merkattu valmiiksi annettujen
"Hakee tietokannasta ne HOKSit, jotka on merkitty valmiiksi annettujen
ajankohtien välillä ja jotka eivät ole TUVA-HOKSeja tai TUVA-HOKSien kanssa
rinnakkaisia ammatillisia HOKSeja."
[from to]
Expand Down
4 changes: 2 additions & 2 deletions src/oph/ehoks/db/queries.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
(defq select-hoksit-created-between "hoksit/select_hoksit_created_between.sql")
(defq select-hoksit-finished-between
"hoksit/select_hoksit_finished_between.sql")
(defq select-non-tuva-hoksit-created-between
"hoksit/select_non_tuva_hoksit_created_between.sql")
(defq select-non-tuva-hoksit-started-between
"hoksit/select_non_tuva_hoksit_started_between.sql")
(defq select-non-tuva-hoksit-finished-between
"hoksit/select_non_tuva_hoksit_finished_between.sql")
(defq select-hoks-oppijat-without-index
Expand Down
6 changes: 4 additions & 2 deletions src/oph/ehoks/palaute/opiskelija.clj
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@
juuri tallennettu."
[kyselytyyppi from to]
(log/info "Reinitiating" kyselytyyppi "for HOKSit between" from "and" to)
(->> (db-hoks/select-non-tuva-hoksit-created-between from to)
(initiate-every-needed! kyselytyyppi)))
(let [fetcher (case kyselytyyppi
:aloituskysely db-hoks/select-non-tuva-hoksit-started-between
:paattokysely db-hoks/select-non-tuva-hoksit-finished-between)]
(initiate-every-needed! kyselytyyppi (fetcher from to))))

(defn create-arvo-kyselylinkki!
"For the given palaute, make Arvo call for creating its kyselylinkki
Expand Down
4 changes: 2 additions & 2 deletions test/oph/ehoks/hoks/hoks_save_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@
["lahetetty" "aloittaneet" (LocalDate/of 2019 3 18)]})
(is (= @sqs-call-counter 3))
(is (= 1 (opalaute/reinitiate-hoksit-between!
:aloituskysely (LocalDate/now) (.plusDays (LocalDate/now) 1))))
:aloituskysely (LocalDate/of 2021 1 1) (LocalDate/of 2021 6 1))))
(is (= @sqs-call-counter 4))
(is (= 1 (opalaute/reinitiate-hoksit-between!
:paattokysely (LocalDate/now) (.plusDays (LocalDate/now) 1))))
:paattokysely (LocalDate/of 2022 12 1) (LocalDate/of 2022 12 30))))
(is (= @sqs-call-counter 5))
(eq (set (map (juxt :tila :kyselytyyppi :heratepvm)
(palaute/get-by-hoks-id-and-kyselytyypit!
Expand Down

0 comments on commit d2afcbc

Please sign in to comment.