Skip to content

Instantly share code, notes, and snippets.

@julesce
Created November 28, 2013 15:46
Show Gist options
  • Select an option

  • Save julesce/7693930 to your computer and use it in GitHub Desktop.

Select an option

Save julesce/7693930 to your computer and use it in GitHub Desktop.
def self.paginate(mailing, filter = :delivered, page = 1, per_page = 30)
page = page.to_i
page = 1 if page < 1
per_page = per_page.to_i
per_page = 30 if per_page < 1
total = mailing.count(filter)
continuation_manager = StatsContinuationManager.new(mailing.promotion, mailing,
{ :page => page,
:per_page => per_page,
:which => filter })
continuation = continuation_manager.retrieve
attempts = mailing.get_promotion_attempts(filter,
{:offset => (page - 1) * per_page,
:limit => per_page,
:continuation => continuation})
continuation_manager.store(attempts.continuation)
build_paginated_set mailing, attempts, page, per_page, total
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment