Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an API Log page to call out changes to values provided by the API.
Changes are stored in the
api_log
table. I'm using an additionalhash
column as a unique identifier for the combination ofdatahub_id
,field
, andvalue
. This gets around the limitation of creating indexes on text columns (the value column).With the exceptions of
id
,main_reference_number
,image_id
, andthumbnail
we are tracking fields defined inARTWORK_API_FIELDS
andGALLERY_API_FIELDS
:The
app:api-log
command is scheduled to run hourly to add entries to the log table.Using the
hash
we can check if adatahub_id
+field
+value
combination exists. This can occur if the value is changed back to a previous value. In those cases, we update theupdated_at
timestamp of the log record.The
getRecentChanges
method uses a MySQL window function which requires MySQL 8 or later. We can get the same results with a few joins, but I found using the LAG function easier to read.The API log page show changes where a previous value exists and is expected to be blank until changes are logged.