Skip to content

Commit

Permalink
Add qualification reference
Browse files Browse the repository at this point in the history
This adds a reference to timeline events for linking them with a
qualification, which allows us to track when the information might have
changed on a qualification.
  • Loading branch information
thomasleese committed Apr 25, 2024
1 parent 84ee108 commit 0505de7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/models/timeline_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# assignee_id :bigint
# creator_id :integer
# note_id :bigint
# qualification_id :bigint
# requestable_id :bigint
# work_history_id :bigint
#
Expand All @@ -39,6 +40,7 @@
# index_timeline_events_on_assessment_section_id (assessment_section_id)
# index_timeline_events_on_assignee_id (assignee_id)
# index_timeline_events_on_note_id (note_id)
# index_timeline_events_on_qualification_id (qualification_id)
# index_timeline_events_on_requestable (requestable_type,requestable_id)
# index_timeline_events_on_work_history_id (work_history_id)
#
Expand All @@ -49,6 +51,7 @@
# fk_rails_... (assessment_section_id => assessment_sections.id)
# fk_rails_... (assignee_id => staff.id)
# fk_rails_... (note_id => notes.id)
# fk_rails_... (qualification_id => qualifications.id)
# fk_rails_... (work_history_id => work_histories.id)
#
class TimelineEvent < ApplicationRecord
Expand All @@ -58,6 +61,7 @@ class TimelineEvent < ApplicationRecord
belongs_to :assignee, class_name: "Staff", optional: true
belongs_to :creator, polymorphic: true, optional: true
belongs_to :note, optional: true
belongs_to :qualification, optional: true
belongs_to :requestable, polymorphic: true, optional: true
belongs_to :work_history, optional: true

Expand Down Expand Up @@ -165,8 +169,9 @@ class TimelineEvent < ApplicationRecord
unless: -> { requestable_reviewed? || requestable_verified? }

validates :column_name, presence: true, if: :information_changed?
validates :work_history_id,
:column_name,
validates :column_name,
:qualification_id,
:work_history_id,
absence: true,
unless: :information_changed?

Expand Down
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
- new_value
- note_id
- old_value
- qualification_id
- requestable_id
- requestable_type
- subjects
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddQualificationToTimelineEvents < ActiveRecord::Migration[7.1]
def change
add_reference :timeline_events, :qualification, foreign_key: true
end
end
5 changes: 4 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions spec/factories/timeline_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# assignee_id :bigint
# creator_id :integer
# note_id :bigint
# qualification_id :bigint
# requestable_id :bigint
# work_history_id :bigint
#
Expand All @@ -37,6 +38,7 @@
# index_timeline_events_on_assessment_section_id (assessment_section_id)
# index_timeline_events_on_assignee_id (assignee_id)
# index_timeline_events_on_note_id (note_id)
# index_timeline_events_on_qualification_id (qualification_id)
# index_timeline_events_on_requestable (requestable_type,requestable_id)
# index_timeline_events_on_work_history_id (work_history_id)
#
Expand All @@ -47,6 +49,7 @@
# fk_rails_... (assessment_section_id => assessment_sections.id)
# fk_rails_... (assignee_id => staff.id)
# fk_rails_... (note_id => notes.id)
# fk_rails_... (qualification_id => qualifications.id)
# fk_rails_... (work_history_id => work_histories.id)
#
FactoryBot.define do
Expand Down
3 changes: 3 additions & 0 deletions spec/models/timeline_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# assignee_id :bigint
# creator_id :integer
# note_id :bigint
# qualification_id :bigint
# requestable_id :bigint
# work_history_id :bigint
#
Expand All @@ -37,6 +38,7 @@
# index_timeline_events_on_assessment_section_id (assessment_section_id)
# index_timeline_events_on_assignee_id (assignee_id)
# index_timeline_events_on_note_id (note_id)
# index_timeline_events_on_qualification_id (qualification_id)
# index_timeline_events_on_requestable (requestable_type,requestable_id)
# index_timeline_events_on_work_history_id (work_history_id)
#
Expand All @@ -47,6 +49,7 @@
# fk_rails_... (assessment_section_id => assessment_sections.id)
# fk_rails_... (assignee_id => staff.id)
# fk_rails_... (note_id => notes.id)
# fk_rails_... (qualification_id => qualifications.id)
# fk_rails_... (work_history_id => work_histories.id)
#
require "rails_helper"
Expand Down

0 comments on commit 0505de7

Please sign in to comment.