Class: Marty::DataChange
- Inherits:
-
Object
- Object
- Marty::DataChange
- Includes:
- Delorean::Model
- Defined in:
- lib/marty/data_change.rb
Constant Summary collapse
- MAX_COUNT =
Some arbitrary limit so we don’t allow enormous queries
64000
Class Method Summary collapse
Class Method Details
.get_changed_data(t0, t1, klass, ids = nil) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/marty/data_change.rb', line 168 def self.get_changed_data(t0, t1, klass, ids=nil) # The following test fails when t0/t1 are infinity. ActiveSupport # doesn't know about infinity. # return unless t0 < t1 change_q = '(obsoleted_dt >= ? AND obsoleted_dt < ?)' + ' OR (created_dt >= ? AND created_dt < ?)' countq = klass.where(change_q, t0, t1, t0, t1) dataq = klass.where(change_q, t0, t1, t0, t1) if ids countq = countq.where(group_id: ids) dataq = dataq.where(group_id: ids) end raise "Change count exceeds limit #{MAX_COUNT}" if countq.count > MAX_COUNT dataq.order("group_id, created_dt").group_by(&:group_id) end |