mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Delete LogEntries older than a month
They are useful for troubleshooting but a month data seems enough.
This commit is contained in:
@@ -35,7 +35,7 @@ class TruncateData
|
||||
def remove_transient_data
|
||||
Spree::ReturnAuthorization.delete_all
|
||||
Spree::StateChange.delete_all("created_at < '#{1.month.ago.to_date}'")
|
||||
Spree::LogEntry.delete_all
|
||||
Spree::LogEntry.delete_all("created_at < '#{1.month.ago.to_date}'")
|
||||
sql_delete_from "sessions"
|
||||
end
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ describe TruncateData do
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
|
||||
it 'deletes log entries older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::LogEntry)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when months_to_keep is nil' do
|
||||
@@ -49,6 +57,14 @@ describe TruncateData do
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
|
||||
it 'deletes log entries older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::LogEntry)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when months_to_keep is specified' do
|
||||
@@ -74,6 +90,14 @@ describe TruncateData do
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
|
||||
it 'deletes log entries older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::LogEntry)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user