Delete LogEntries older than a month

They are useful for troubleshooting but a month data seems enough.
This commit is contained in:
Pau Perez
2020-03-10 13:10:52 +01:00
parent 5f84c51c13
commit 0f1d57db73
2 changed files with 25 additions and 1 deletions

View File

@@ -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

View File

@@ -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