Skip to content

Commit

Permalink
IS-2401: Adjust status endring model (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad authored May 28, 2024
1 parent dd6c674 commit 7501399
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const val queryCreateDialogmoteStatus =
created_at,
personident,
mote_tidspunkt,
ferdigstilt_tidspunkt
) values (DEFAULT, ?, ?, ?, ?, ?)
status_tidspunkt,
status_type
) values (DEFAULT, ?, ?, ?, ?, ?, ?)
RETURNING id
"""

Expand All @@ -30,7 +31,8 @@ fun Connection.createDialogmoteStatus(
it.setObject(2, dialogmoteStatusEndring.createdAt)
it.setString(3, dialogmoteStatusEndring.personIdentNumber.value)
it.setObject(4, dialogmoteStatusEndring.moteTidspunkt)
it.setObject(5, dialogmoteStatusEndring.ferdigstiltTidspunkt)
it.setObject(5, dialogmoteStatusEndring.statusTidspunkt)
it.setString(6, dialogmoteStatusEndring.type.name)
it.executeQuery().toList { getInt("id") }
}

Expand All @@ -44,10 +46,10 @@ fun Connection.createDialogmoteStatus(

const val queryGetLatestDialogmoteFerdigstiltForPerson =
"""
SELECT ferdigstilt_tidspunkt
SELECT status_tidspunkt
FROM DIALOGMOTESTATUS
WHERE personident = ?
ORDER BY ferdigstilt_tidspunkt DESC;
WHERE personident = ? AND status_type = 'FERDIGSTILT'
ORDER BY status_tidspunkt DESC;
"""

fun Connection.getLatestDialogmoteFerdigstiltForPerson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class DialogmoteStatusEndring private constructor(
val type: DialogmoteStatusEndringType,
val createdAt: OffsetDateTime,
val moteTidspunkt: OffsetDateTime,
val ferdigstiltTidspunkt: OffsetDateTime,
val statusTidspunkt: OffsetDateTime,
) {
companion object {
fun create(kafkaDialogmoteStatusEndring: KDialogmoteStatusEndring) = DialogmoteStatusEndring(
Expand All @@ -29,7 +29,7 @@ data class DialogmoteStatusEndring private constructor(
kafkaDialogmoteStatusEndring.getDialogmoteTidspunkt(),
ZoneOffset.UTC,
),
ferdigstiltTidspunkt = OffsetDateTime.ofInstant(
statusTidspunkt = OffsetDateTime.ofInstant(
kafkaDialogmoteStatusEndring.getStatusEndringTidspunkt(),
ZoneOffset.UTC,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE DIALOGMOTESTATUS RENAME COLUMN ferdigstilt_tidspunkt TO status_tidspunkt;
ALTER TABLE DIALOGMOTESTATUS ADD COLUMN status_type VARCHAR(50) NOT NULL DEFAULT 'FERDIGSTILT';
ALTER TABLE DIALOGMOTESTATUS ALTER COLUMN status_type DROP DEFAULT;

0 comments on commit 7501399

Please sign in to comment.