use ruby time

pull/10886/head
ulferts 2 years ago
parent a7febaf6a0
commit 76527d46d2
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 12
      app/services/journals/create_service.rb

@ -228,7 +228,7 @@ module Journals
journals
SET
notes = :notes,
updated_at = #{journal_timestamp_sql(notes, ':updated_at')},
updated_at = #{timestamp_sql},
data_id = insert_data.id
FROM insert_data
WHERE journals.id = :predecessor_id
@ -238,7 +238,6 @@ module Journals
sanitize(journal_sql,
notes: notes.presence || predecessor.notes,
updated_at: journable_timestamp,
predecessor_id: predecessor.id)
end
@ -568,10 +567,17 @@ module Journals
if notes.blank? && journable_timestamp
attribute
else
'now()'
timestamp_sql
end
end
def timestamp_sql
# Use the ruby time instead of the DB's. If those are out of sync,
# a journal might otherwise end up having an updated_at before created_at which
# will also reflect back to the journaled object.
"'#{Time.zone.now}'"
end
# Because we added the journal via bare metal sql, rails does not yet
# know of the journal. If the journable has the journals loaded already,
# the caller might expect the journals to also be updated so we do it for him.

Loading…
Cancel
Save