Skip to content

Commit

Permalink
EVSS: Add other documents to events timeline (#444)
Browse files Browse the repository at this point in the history
* EVSS: Add other documents to events timeline

Refs https://github.com/department-of-veterans-affairs/sunsets-team/issues/197

* Add date to objects

* Clearer spec
  • Loading branch information
earthboundkid authored Nov 4, 2016
1 parent 4d8f0a9 commit c3fc556
Show file tree
Hide file tree
Showing 3 changed files with 720 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/serializers/disability_claim_detail_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def events_timeline
# Add tracked items
events += create_events_for_tracked_items

# Add documents not associated with a tracked item
events += create_events_for_documents

# Make reverse chron with nil date items at the end
events.compact.sort_by { |h| h[:date] || Date.new }.reverse
end
Expand Down Expand Up @@ -66,6 +69,15 @@ def create_events_for_tracked_items
end.flatten
end

def create_events_for_documents
# Objects with trackedItemId are part of other events, so don't duplicate them
docs = sub_objects_of('vbaDocumentList').select { |obj| obj['trackedItemId'].nil? }
docs = create_documents docs
docs.map do |obj|
obj.merge(type: :other_documents_list, date: obj[:upload_date])
end
end

# Order of EVENT_DATE_FIELDS determines which date trumps in timeline sorting
EVENT_DATE_FIELDS = %i(
closed_date
Expand Down
Loading

0 comments on commit c3fc556

Please sign in to comment.