Created
November 28, 2013 15:46
-
-
Save julesce/7693930 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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