0.0
No commit activity in last 3 years
No release in over 3 years
Get GlobalIDs from an ActiveRecord scope without instantiating AR objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
~> 3

Runtime

~> 0.3.0
>= 4.0
 Project Readme

pluck_global_id

Helper method to easily get GlobalIDs from an ActiveRecord scope without instantiating AR objects.

Useful for mass-creating ActiveJob jobs from a specific subset of your records.

Installation

Add this line to your application's Gemfile:

gem 'pluck_global_id'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pluck_global_id

Usage

Use pluck_global_id when you want to instantiate ActiveJob from a scope:

user_gids = User.where(active: true).pluck_global_id
user_gids.each do |user_gid|
  UserWorker.perform_later(user_gid)
end

This avoids costly AR objects which often consume 2x memory (or more) in such cases, even when using select(:id).

Contributing

  1. Fork it ( https://github.com/lfittl/pluck_global_id/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request