snthpr1d3 / activerecord-prunable Goto Github PK
View Code? Open in Web Editor NEWConvenient removal of obsolete records for ActiveRecord models.
License: MIT License
Convenient removal of obsolete records for ActiveRecord models.
License: MIT License
This library requires a prunable
scope in each model. That's fine.
But we noticed that we often define these scopes in the same way:
class Entity < ApplicationRecord
include ActiveRecord::Prunable
TTL = 7.days
scope :prunable, -> (time = Time.current) { where('created_at < ?', time - TTL) }
It would have been cool if we could write less code for the same effect.
For example:
class Entity < ApplicationRecord
include ActiveRecord::Prunable
prune_after 7.days
Perhaps it will also be nice to have 2 such methods: for created_at
and for updated_at
fields, which are standard in all AR models.
If you agree that this is a good idea, but don't have time to implement it, you will get a pull request for it.
What do you think?
At the moment, removal is performed via delete_all or destroy_all, which may not be optimal in the case of a large number of deleting records, along with a complex removal condition. It seems to me that it will be useful to add batch removal - for example, with each_slice.
Version 0.3.1 requires the version of Rails < 5.0. Therefore, an error occurs during the installation:
Downloading activerecord-prunable-0.3.1 revealed dependencies not in the API or the lockfile (activerecord (< 5.0, >= 3.0), activesupport (< 5.0, >= 3.0)).
Can you update the dependencies so that this wonderful library works for Rails 5?
When using version 0.2.1, there was no such problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.