Add: Prune reports that match a specific status#311
Add: Prune reports that match a specific status#311Nold360 wants to merge 5 commits intosodabrew:masterfrom Nold360:master
Conversation
lib/tasks/prune_reports.rake
Outdated
|
This is awesome! A few comments inlined above. |
|
Hi, thanks a lot for your comments. |
app/models/node.rb
Outdated
There was a problem hiding this comment.
I missed this one, same change as in the other file:
.where("reports.time < ? AND reports.status #{condition} ?", cutoff, status)
|
Fixed that, too. |
lib/tasks/prune_reports.rake
Outdated
|
The default behavior should be to delete reports of any status older than the given date, but I think the way the queries are written, you must supply a status, otherwise it won't delete anything? |
|
Cleanup done. The default behavior is just as it has been before. If you don't specify status & condition, it will become: which will match every status in that table. |
|
Oh, gotcha. I would worry about a performance impact from this; the reports table tends to be huge. The index covering add_index "reports", ["time", "node_id", "status"], :name => "index_reports_on_time_and_node_id_and_status" |
|
Hm, I'm not really into databases, so I can't tell. |
|
We could change the default values for status and/or condition to "nil" and build the query in a if-condition f.e.: I don't know if the syntax for the strings is correct, but that could be the way to go. |
|
@Nold360 hi thanks for the feature! this sounds really great but I notice your source repo has disappeared! if you want to work on this some more I can help |
Hi,
I've added the possibility to prune reports based on their status.
F.e. it's now possible to prune only reports that have the status "unchanged".
Examples:
RAILS_ENV=production bundle exec rake reports:prune unit=mon upto=1 condition=is status=unchanged
RAILS_ENV=production bundle exec rake reports:prune unit=mon upto=1 condition=not status=changed
Since this is the first time I've been codeing ruby, the changes will be most likely not that nice. I hope you like the feature anyway.
Best Regards,
Nold