alphagov/EFG — pull request #124 by tjmw (2013-02-28 17:43:13+00:00)
Title: Fix last modified date on loan reports

Currently the last modified start/end dates which can be specified on loan reports are compared to loans.updated_at in the underlying query. This is problematic since updated_at is updated to now by Rails any time a row is touched, including data migrations and imports.

This change introduces a new last_modified_at column on the loans table, which is kept in sync with the modified_at value of the latest loan_state_changes row for the loan. The new loans.last_modified_at column is then used in loan report generation, giving more meaningful results than updated_at.