Skip to content

Commit

Permalink
Merge branch 'main' into changelog-v3.52.12
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyprivett authored Dec 18, 2024
2 parents fcc7ebe + 2d25e1e commit 89ef0e8
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 740 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [v3.53.0](https://github.com/ministryofjustice/hmpps-book-secure-move-api/tree/v3.53.0) (2024-12-18)

[Full Changelog](https://github.com/ministryofjustice/hmpps-book-secure-move-api/compare/v3.52.12...v3.53.0)

**Merged pull requests:**

- MAP-1975: Add the preprod refresh versions script [\#2449](https://github.com/ministryofjustice/hmpps-book-secure-move-api/pull/2449) ([jimbali](https://github.com/jimbali))
- chore\(deps\): Bump the production-dependencies group with 3 updates [\#2448](https://github.com/ministryofjustice/hmpps-book-secure-move-api/pull/2448) ([dependabot[bot]](https://github.com/apps/dependabot))
- MAP-1917 Add a PerSuicideAndSelfHarm event [\#2443](https://github.com/ministryofjustice/hmpps-book-secure-move-api/pull/2443) ([tobyprivett](https://github.com/tobyprivett))

## [v3.52.12](https://github.com/ministryofjustice/hmpps-book-secure-move-api/tree/v3.52.12) (2024-12-16)

[Full Changelog](https://github.com/ministryofjustice/hmpps-book-secure-move-api/compare/v3.52.11...v3.52.12)
Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,14 @@ GEM
rb-inotify (0.11.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdoc (6.9.0)
rdoc (6.9.1)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
redis-client (0.23.0)
connection_pool
regexp_parser (2.9.3)
reline (0.5.12)
reline (0.6.0)
io-console (~> 0.5)
request_store (1.7.0)
rack (>= 1.4)
Expand Down Expand Up @@ -469,15 +469,15 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
securerandom (0.4.0)
sentry-rails (5.22.0)
securerandom (0.4.1)
sentry-rails (5.22.1)
railties (>= 5.0)
sentry-ruby (~> 5.22.0)
sentry-ruby (5.22.0)
sentry-ruby (~> 5.22.1)
sentry-ruby (5.22.1)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
sentry-sidekiq (5.22.0)
sentry-ruby (~> 5.22.0)
sentry-sidekiq (5.22.1)
sentry-ruby (~> 5.22.1)
sidekiq (>= 3.0)
service_mock (0.9)
childprocess (~> 0.5)
Expand Down
2 changes: 2 additions & 0 deletions app/models/generic_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class GenericEvent < ApplicationRecord
PerPrisonerWelfare
PerPropertyChange
PerSelfHarm
PerSuicideAndSelfHarm
PerUpdated
PerViolentDangerous
PerWeapons
Expand All @@ -110,6 +111,7 @@ class GenericEvent < ApplicationRecord
incident: 'incident',
medical: 'medical',
notification: 'notification',
suicide_and_self_harm: 'suicide_and_self_harm',
}

belongs_to :eventable, polymorphic: true, touch: true
Expand Down
32 changes: 32 additions & 0 deletions app/models/generic_event/per_suicide_and_self_harm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class GenericEvent
class PerSuicideAndSelfHarm < GenericEvent
LOCATION_ATTRIBUTE_KEY = :location_id

details_attributes :indication_of_self_harm_or_suicide,
:nature_of_self_harm,
:history_of_self_harm,
:history_of_self_harm_recency,
:history_of_self_harm_method,
:history_of_self_harm_details,
:actions_of_self_harm_undertaken,
:observation_level,
:comments,
:reporting_officer,
:reporting_officer_signed_at,
:reception_officer,
:reception_officer_signed_at,
:supplier_personnel_number,
:police_personnel_number

relationship_attributes location_id: :locations
eventable_types 'PersonEscortRecord'

include PersonnelNumberValidations
include LocationFeed
include LocationValidations

def event_classification
:suicide_and_self_harm
end
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "create-temp-tables" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "copy-from-temp-sql" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "drop-temp-tables" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $fullName }}
data:
entrypoint.sh: |-
#!/bin/bash
from=$(date --date="2 days ago" '+%Y-%m-%d')
to=$(date '+%Y-%m-%d')
from=$(date --date="{{ .Values.scripts.preprodRefresh.main.dataSince }}" '+%Y-%m-%d %T')
to=$(date '+%Y-%m-%d %T')
echo "Refreshing data from ${from} to ${to}"
createTemp='/tmp/sql/createTables.sql'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
{{- $script2 := printf "%s-%s" (include "generic-service.fullname" $) "copy-from-temp-sql" | trunc 52 }}
{{- $script3 := printf "%s-%s" (include "generic-service.fullname" $) "drop-temp-tables" | trunc 52 }}
{{- $script4 := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ $fullName }}
spec:
schedule: {{ .Values.scripts.preprodRefresh.schedule }}
schedule: {{ .Values.scripts.preprodRefresh.main.schedule }}
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-vers-scrp" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.versions.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: preprod-refresh-versions-script
name: {{ $fullName }}
data:
entrypoint.sh: |-
#!/bin/bash
from=$(date --date="26 hours ago" '+%Y-%m-%d %T')
from=$(date --date="{{ .Values.scripts.preprodRefresh.versions.dataSince }}" '+%Y-%m-%d %T')
to=$(date '+%Y-%m-%d %T')
echo "Refreshing versions from ${from} to ${to}"
Expand Down Expand Up @@ -38,4 +40,5 @@ data:
echo "Dropping temporary tables"
execDest "DROP TABLE IF EXISTS versions_temp CASCADE;"
execSource "DROP TABLE IF EXISTS versions_temp CASCADE;"
echo "All done!"
echo "All done!"
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- $genericService := index .Values "generic-service" -}}
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-versions" | trunc 52 }}
{{- $script1 := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-versions-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.versions.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: preprod-refresh-versions-job
name: {{ $fullName }}
spec:
schedule: "15 7 * * *"
schedule: {{ .Values.scripts.preprodRefresh.versions.schedule }}
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
Expand Down Expand Up @@ -43,5 +47,6 @@ spec:
volumes:
- name: preprod-refresh-versions-script
configMap:
name: preprod-refresh-versions-script
defaultMode: 0755
name: {{ $script1 }}
defaultMode: 0755
{{- end }}
10 changes: 8 additions & 2 deletions helm_deploy/hmpps-book-secure-move-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ dashboards:

scripts:
preprodRefresh:
enabled: false
# schedule: "15 6 * * *"
main:
enabled: false
# schedule: "0 */4 * * *"
# dataSince: "6 hours ago"
versions:
enabled: false
# schedule: "15 7 * * *"
# dataSince: "26 hours ago"
reports:
enabled: false
dailyIpt:
Expand Down
10 changes: 8 additions & 2 deletions helm_deploy/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ dashboards:

scripts:
preprodRefresh:
enabled: true
schedule: "15 6 * * *"
main:
enabled: true
schedule: "0 */4 * * *"
dataSince: "6 hours ago"
versions:
enabled: true
schedule: "15 7 * * *"
dataSince: "26 hours ago"
reports:
enabled: true
dailyIpt:
Expand Down
43 changes: 0 additions & 43 deletions preprod-refresh/01-create-temp-tables-sql.yaml

This file was deleted.

Loading

0 comments on commit 89ef0e8

Please sign in to comment.