Skip to content

Commit

Permalink
Rename database fields
Browse files Browse the repository at this point in the history
date to observation_time and end_date to observation_time_end
  • Loading branch information
pvannierop committed Jun 17, 2024
1 parent 0ec903b commit 147857b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class ObservationDto(
val category: String?,

/** Date or date-time of the observation. */
val date: String?,
val observation_time: String?,

/**
* For how long the observation was valid. Null if there is no duration, or if the observation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ fun Observation.toDto(): ObservationDto = ObservationDto(
source = source,
topic = topic,
category = category,
date = date.toString(),
period = if (endDate != null) {
Duration.between(date, endDate).toString()
observation_time = observationTime.toString(),
period = if (observationTimeEnd != null) {
Duration.between(observationTime, observationTimeEnd).toString()
} else {
null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data class Observation(
@Id
val source: String,

@Column(nullable = false)
@Column(nullable = false, name = "topic_name")
@Id
val topic: String,

Expand All @@ -49,12 +49,12 @@ data class Observation(
@Id
val variable: String,

@Column(nullable = false)
@Column(nullable = false, name = "observation_time")
@Id
val date: ZonedDateTime,
val observationTime: ZonedDateTime,

@Column(name = "end_date")
val endDate: ZonedDateTime?,
@Column(name = "observation_time_end")
val observationTimeEnd: ZonedDateTime?,

@Column(name = "value_textual")
val valueTextual: String?,
Expand All @@ -72,11 +72,11 @@ data class Observation(
topic == other.topic &&
category == other.category &&
variable == other.variable &&
date == other.date &&
endDate == other.endDate
observationTime == other.observationTime &&
observationTimeEnd == other.observationTimeEnd
}

override fun hashCode(): Int = Objects.hash(subject, variable, date)
override fun hashCode(): Int = Objects.hash(subject, variable, observationTime)

companion object {
internal fun String?.toPrintString() = if (this != null) "'$this'" else "null"
Expand Down

0 comments on commit 147857b

Please sign in to comment.