-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from co-cddo/add-update-record
Add record of updates to the system
- Loading branch information
Showing
15 changed files
with
362 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class UpdateLogsController < ApplicationController | ||
def index | ||
@update_logs = UpdateLog.order(updated_on: :desc, created_at: :desc) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class UpdateLog < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class LogUpdates | ||
def self.after(time) | ||
new(time:).update_log | ||
end | ||
|
||
attr_reader :time | ||
|
||
def initialize(time:) | ||
@time = time | ||
end | ||
|
||
def update_log | ||
return unless changes? | ||
|
||
@update_log ||= UpdateLog.create!(updated_on: time, comment: report) | ||
end | ||
|
||
def report | ||
return unless changes? | ||
return created_text if updated_ids.empty? | ||
|
||
[ | ||
created_text, | ||
"Additionally, entries with the following ID numbers have been updated:", | ||
updated_ids.to_sentence, | ||
].join(" ") | ||
end | ||
|
||
def created_text | ||
[ | ||
number_created, | ||
"Agreement".pluralize(number_created), | ||
"created.", | ||
].join(" ") | ||
end | ||
|
||
def changes? | ||
number_created.positive? || updated_ids.present? | ||
end | ||
|
||
def number_created | ||
@number_created ||= Agreement.where(created_at: time..).count | ||
end | ||
|
||
def updated_ids | ||
@updated_ids ||= Agreement.where(updated_at: time..) | ||
.where.not(created_at: time..) | ||
.pluck(Arel.sql("fields->'ID'")) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<% page_title = "Update Log" %> | ||
|
||
<h1 class="govuk-heading-l">Record of updates</h1> | ||
|
||
<%= | ||
govuk_summary_list do |summary_list| | ||
@update_logs.each do |update_log| | ||
summary_list.with_row do |row| | ||
row.with_key(text: update_log.updated_on.strftime("%d %B %Y")) | ||
row.with_value(text: update_log.comment) | ||
end | ||
end | ||
end | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateUpdateLogs < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :update_logs do |t| | ||
t.date :updated_on | ||
t.string :comment | ||
t.boolean :from_seeds, default: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
- date: 14 May 2024 | ||
text: A new searchable version of the register has been uploaded replacing the spreadsheet attachment | ||
|
||
- date: 5 March 2024 | ||
text: new entries added | ||
|
||
- date: 20 February 2024 | ||
text: new entries added | ||
|
||
- date: 27 November 2023 | ||
text: register updated | ||
|
||
- date: 30 October 2023 | ||
text: New entries added. | ||
|
||
- date: 28 September 2023 | ||
text: Register updated | ||
|
||
- date: 2 August 2023 | ||
text: "New register entries added. Additionally, entries with the following ID numbers have been updated: 60,64,92,96 and 215." | ||
|
||
- date: 31 March 2023 | ||
text: New entries added | ||
|
||
- date: 9 February 2023 | ||
text: new entries amended | ||
|
||
- date: 9 February 2023 | ||
text: New entries added | ||
|
||
- date: 9 January 2023 | ||
text: Entries added | ||
|
||
- date: 8 December 2022 | ||
text: New entries added | ||
|
||
- date: 9 August 2022 | ||
text: New entries added. End date of debt pilots on lines 97 - 137 updated. | ||
|
||
- date: 1 July 2022 | ||
text: New entries added. | ||
|
||
- date: 17 May 2022 | ||
text: New entry added. | ||
|
||
- date: 10 May 2022 | ||
text: New entries added. The end date for three water poverty ISAs 94,95,96 have also been amended. | ||
|
||
- date: 27 April 2022 | ||
text: New entry added | ||
|
||
- date: 8 April 2022 | ||
text: new entry added. | ||
|
||
- date: 30 March 2022 | ||
text: New entries added | ||
|
||
- date: 13 January 2022 | ||
text: Register entry no.88 removed. | ||
|
||
- date: 7 January 2022 | ||
text: Register updated. New entries added. ID ref 97, new controllers added. | ||
|
||
- date: 9 November 2021 | ||
text: Register updated. New entries added. | ||
|
||
- date: 18 October 2021 | ||
text: Register updated | ||
|
||
- date: 17 September 2021 | ||
text: Register updated | ||
|
||
- date: 14 September 2021 | ||
text: Register updated. | ||
|
||
- date: 1 September 2021 | ||
text: Register updated | ||
|
||
- date: 28 July 2021 | ||
text: Register updated | ||
|
||
- date: 14 July 2021 | ||
text: Register updated | ||
|
||
- date: 24 June 2021 | ||
text: Register updated. | ||
|
||
- date: 27 May 2021 | ||
text: Register update | ||
|
||
- date: 12 May 2021 | ||
text: Register updated | ||
|
||
- date: 30 April 2021 | ||
text: First published. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :update_log do | ||
updated_on { 2.days.ago.to_date } | ||
comment { Faker::Lorem.sentence } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "UpdateLogs", type: :request do | ||
describe "GET /index" do | ||
let!(:update_log) { create :update_log } | ||
|
||
it "displays log" do | ||
get update_logs_path | ||
expect(response.body).to include(update_log.comment) | ||
end | ||
end | ||
end |
Oops, something went wrong.