GithubHelp home page GithubHelp logo

activerecord-prunable's People

Contributors

caron10 avatar snthpr1d3 avatar vassilevsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

activerecord-prunable's Issues

Add convenience methods for common prunable conditions

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?

Add batch removal

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.

Update dependencies

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.