This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Limit (cost=0.11..4232.55 rows=1000 width=4) | |
-> Index Scan using lease_deals_pkey on lease_deals (cost=0.11..3130311.24 rows=739600 width=4) | |
Filter: ((expired_at IS NULL) AND (updated_at < '2018-10-09 09:26:33.507679'::timestamp without time zone) AND (dealership_id = 5678)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Snippets taken from: | |
# https://github.com/rails/rails/blob/fc5dd0b85189811062c85520fd70de8389b55aeb/activerecord/lib/active_record/relation/batches.rb#L201 | |
def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore: nil) | |
relation = self | |
# ... | |
batch_limit = of | |
# ... | |
relation = relation.reorder(batch_order).limit(batch_limit) | |
relation = apply_limits(relation, start, finish) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LeaseDeal < ApplicationRecord | |
def self.expire_all(time: Time.current, batch_size: 1000) | |
ids = pluck(:id) | |
ids.each_slice(batch_size) do |ids_slice| | |
unscoped.where(id: ids_slice).update_all(expired_at: time) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddOrderedDealershipIdExpiredAtIndexToLeaseDeals < ActiveRecord::Migration[5.2] | |
def change | |
remove_index :lease_deals, name: :index_lease_deals_on_dealership_id_and_expired_at, algorithm: :concurrently | |
add_index :lease_deals, %i[id dealership_id expired_at], where: 'expired_at IS NULL', using: :btree, order: { id: :asc }, algorithm: :concurrently | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# German rails_admin translation | |
de: | |
admin: | |
home: | |
name: "Home" | |
pagination: | |
previous: "« Vor" | |
next: "Zurück »" | |
truncate: "…" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def no_duplicates? | |
tally.values.all? {|v| v == 1 } | |
end | |
end | |
class Card | |
attr_reader :picture, :suit | |
def initialize(picture, suit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
alias ⏪ << | |
alias 🈴 concat | |
alias 💧 drop | |
alias 🔁 each | |
alias 🈳❓ empty? | |
alias 🍀 sample | |
alias 🎲 sample | |
alias ♻️ shuffle | |
alias 👈 push |
OlderNewer