Skip to content

Instantly share code, notes, and snippets.

@garethson
Last active July 17, 2019 17:01
Show Gist options
  • Save garethson/771d219cb13354563a9b8b07255568ed to your computer and use it in GitHub Desktop.
Save garethson/771d219cb13354563a9b8b07255568ed to your computer and use it in GitHub Desktop.
Pagination testing

Products with order by

irb(main):013:0> products = ShopifyAPI::Product.find(:all, params: { order: 'inventory_total desc', limit: 250 })
=> [[1927082278968, 300], [1927082836024, 300], [1927082803256, 300], [1927082770488, 300], [1927082311736, 300], [1931623825464, 900], [1927082410040, 300], [1927082377272, 300], [1927082606648, 300], [1927082573880, 300], [1974167830584, 500], [1931371839544, 500], [1927082868792, 300], [1927082704952, 300], [1927082672184, 300], [1927082639416, 300], [1927082508344, 300], [1927082475576, 300], [1927082442808, 300], [1974003073080, 200], [1972226621496, 200], [1931627724856, 200], [1931547148344, 200], [1931522900024, 200], [1931459657784, 200], [1928719499320, 200], [1927082737720, 100], [1972315390008, 9], [1972312703032, 9], [1972304904248, 9], [1972288913464, 9], [1972286685240, 9], [1972286128184, 9], [1972285472824, 9], [1972284915768, 9], [1972284194872, 9], [1972277870648, 9], [1972276789304, 9], [1972205191224, 45], [1972312047672, 9], [1972287275064, 9], [1972283473976, 9], [1972278493240, 9], [1933201047608, 9], [1933189218360, 9], [1933188661304, 9], [1933188104248, 9], [1933186924600, 9], [1974002614328, 20], [1972226162744, 20], [1931627233336, 20], [1931546689592, 20], [1931522441272, 20], [1931459002424, 20], [1927082901560, 15], [1972315783224, 1], [1972313096248, 1], [1972312440888, 1], [1972305428536, 1], [1972293304376, 1], [1972287668280, 1], [1972287078456, 1], [1972286521400, 1], [1972285866040, 1], [1972285308984, 1], [1972284588088, 1], [1972283867192, 1], [1972278886456, 1], [1972278263864, 1], [1972277182520, 1], [1970117509176, 1], [1970115805240, 1], [1970112856120, 1], [1928477507640, 5], [1928477474872, 5], [1928477442104, 5], [1928477409336, 5], [1928477376568, 5], [1928477343800, 5], [1928477311032, 5], [1928477278264, 5], [1928477245496, 5], [1974002810936, 5], [1972226359352, 5], [1931627429944, 5], [1931546886200, 5], [1931522637880, 5], [1931459297336, 5], [1972315684920, 1], [1972312997944, 1], [1972312342584, 1], [1972305297464, 1], [1972293173304, 1], [1972287569976, 1], [1972286980152, 1], [1972286423096, 1], [1972285767736, 1], [1972285210680, 1], [1972284489784, 1], [1972283768888, 1], [1972278788152, 1], [1972278165560, 1], [1972277084216, 1], [1930817372216, 2], [1930817142840, 3], [1930657955896, 2], [1930657726520, 3], [1930657693752, 2], [1930657464376, 3], [1930657431608, 2], [1930657202232, 3], [1930657169464, 2], [1930656940088, 3], [1930275192888, 2], [1930274963512, 3], [1929510551608, 2], [1929510158392, 3], [1929293398072, 2], [1929293168696, 3], [1929054486584, 2], [1929054257208, 3], [1929054224440, 2], [1929053995064, 3], [1929053798456, 2], [1929053569080, 3], [1929053470776, 2], [1929053241400, 3], [1929047736376, 2], [1929047507000, 3], [1929047408696, 2], [1929047179320, 3], [1929047146552, 2], [1929046917176, 3], [1929046884408, 2], [1929046655032, 3], [1929046589496, 2], [1929046360120, 3], [1929046229048, 2], [1929045999672, 3], [1928749350968, 2], [1928749121592, 3], [1928738734136, 2], [1928738504760, 3], [1928738275384, 2], [1928738046008, 3], [1928726315064, 2], [1928726052920, 3], [1928725135416, 2], [1928724873272, 3], [1928723038264, 2], [1928722808888, 3], [1928722448440, 2], [1928722186296, 3], [1928721596472, 2], [1928721334328, 3], [1928720973880, 2], [1928720744504, 3], [1928720547896, 2], [1928720318520, 3], [1928719958072, 2], [1928719695928, 3], [1928719532088, 2], [1928719269944, 3], [1928719040568, 2], [1928718811192, 3], [1928704753720, 2], [1928704491576, 3], [1928690106424, 2], [1928689844280, 3], [1930817339448, 2], [1930817306680, 2], [1930657923128, 2], [1930657890360, 2], [1930657660984, 2], [1930657628216, 2], [1930657398840, 2], [1930657366072, 2], [1930657136696, 2], [1930657103928, 2], [1930275160120, 2], [1930275127352, 2], [1929510486072, 2], [1929510420536, 2], [1929293365304, 2], [1929293332536, 2], [1929054453816, 2], [1929054421048, 2], [1929054191672, 2], [1929054158904, 2], [1929053765688, 2], [1929053732920, 2], [1929053438008, 2], [1929053405240, 2], [1929047703608, 2], [1929047670840, 2], [1929047375928, 2], [1929047343160, 2], [1929047113784, 2], [1929047081016, 2], [1929046851640, 2], [1929046818872, 2], [1929046556728, 2], [1929046523960, 2], [1929046196280, 2], [1929046163512, 2], [1928749318200, 2], [1928749285432, 2], [1928738701368, 2], [1928738668600, 2], [1928738242616, 2], [1928738209848, 2], [1928726282296, 2], [1928726216760, 2], [1928725102648, 2], [1928725069880, 2], [1928723005496, 2], [1928722972728, 2], [1928722415672, 2], [1928722382904, 2], [1928721563704, 2], [1928721498168, 2], [1928720941112, 2], [1928720908344, 2], [1928720515128, 2], [1928720482360, 2], [1928719925304, 2], [1928719859768, 2], [1928719466552, 2], [1928719007800, 2], [1928718975032, 2], [1928704720952, 2], [1928704655416, 2], [1928690073656, 2], [1928690040888, 2], [1972315815992, 1], [1972315652152, 1], [1972315619384, 1], [1972315521080, 1], [1972315324472, 1], [1972315291704, 1], [1972313129016, 1], [1972312965176, 1], [1972312932408, 1], [1972312834104, 1], [1972312637496, 1], [1972312604728, 1], [1972312473656, 1], [1972312309816, 1], [1972312277048, 1], [1972312178744, 1]]

irb(main):019:0> products.next_page?
=> true
irb(main):020:0> products = products.fetch_next_page
irb(main):021:0> products.map { |p| [p.id, p.variants.first.inventory_quantity] }
=> [[1972311982136, 1], [1972311949368, 1], [1972305494072, 1], [1972305264696, 1], [1972305231928, 1], [1972305068088, 1], [1972304805944, 1], [1972304740408, 1], [1972293402680, 1], [1972293140536, 1], [1972293107768, 1], [1972293009464, 1], [1972288847928, 1], [1972288815160, 1], [1972287701048, 1], [1972287537208, 1], [1972287504440, 1], [1972287406136, 1], [1972287209528, 1], [1972287176760, 1], [1972287111224, 1], [1972286947384, 1], [1972286914616, 1], [1972286816312, 1], [1972286619704, 1], [1972286586936, 1], [1972286554168, 1], [1972286390328, 1], [1972286357560, 1], [1972286259256, 1], [1972286062648, 1], [1972286029880, 1], [1972285898808, 1], [1972285734968, 1], [1972285702200, 1], [1972285603896, 1], [1972285407288, 1], [1972285374520, 1], [1972285341752, 1], [1972285177912, 1], [1972285145144, 1], [1972285046840, 1], [1972284850232, 1], [1972284817464, 1], [1972284620856, 1], [1972284457016, 1], [1972284424248, 1], [1972284325944, 1], [1972284129336, 1], [1972284096568, 1], [1972283899960, 1], [1972283736120, 1], [1972283703352, 1], [1972283605048, 1], [1972283408440, 1], [1972283375672, 1], [1972278919224, 1], [1972278755384, 1], [1972278722616, 1], [1972278624312, 1], [1972278427704, 1], [1972278394936, 1], [1972278296632, 1], [1972278132792, 1], [1972278100024, 1], [1972278001720, 1], [1972277805112, 1], [1972277772344, 1], [1972277215288, 1], [1972277051448, 1], [1972277018680, 1], [1972276920376, 1], [1972276723768, 1], [1972276691000, 1], [1972205158456, 1], [1972205125688, 1], [1972205092920, 1], [1972205027384, 1], [1970117541944, 1], [1970117410872, 1], [1970117378104, 1], [1970117279800, 1], [1970117115960, 1], [1970117083192, 1], [1970115870776, 1], [1970115674168, 1], [1970115608632, 1], [1970115510328, 1], [1970115280952, 1], [1970115248184, 1], [1970112888888, 1], [1970112757816, 1], [1970112725048, 1], [1970112626744, 1], [1970112462904, 1], [1970112430136, 1], [1933201440824, 1], [1933201309752, 1], [1933201276984, 1], [1933201178680, 1], [1933200982072, 1], [1933200949304, 1], [1933189611576, 1], [1933189480504, 1], [1933189447736, 1], [1933189349432, 1], [1933189152824, 1], [1933189120056, 1], [1933189054520, 1], [1933188923448, 1], [1933188890680, 1], [1933188792376, 1], [1933188595768, 1], [1933188563000, 1], [1933188497464, 1], [1933188366392, 1], [1933188333624, 1], [1933188235320, 1], [1933188038712, 1], [1933188005944, 1], [1933187317816, 1], [1933187186744, 1], [1933187153976, 1], [1933187055672, 1], [1933186859064, 1], [1933186826296, 1], [1930817273912, 1], [1930657857592, 1], [1930657595448, 1], [1930657333304, 1], [1930657071160, 1], [1930275094584, 1], [1929510322232, 1], [1929293299768, 1], [1929054388280, 1], [1929054126136, 1], [1929053700152, 1], [1929053372472, 1], [1929047638072, 1], [1929047310392, 1], [1929047048248, 1], [1929046786104, 1], [1929046491192, 1], [1929046130744, 1], [1928749252664, 1], [1928738635832, 1], [1928738177080, 1], [1928726183992, 1], [1928725037112, 1], [1928722939960, 1], [1928722350136, 1], [1928721465400, 1], [1928720875576, 1], [1928720449592, 1], [1928719827000, 1], [1928719401016, 1], [1928718942264, 1], [1928704622648, 1], [1928690008120, 1], [1972205223992, 0], [1972205060152, 0], [1969246306360, 0], [1969246273592, 0], [1969152557112, 0], [1969152524344, 0], [1969152491576, 0], [1969152458808, 0], [1969152426040, 0], [1969152393272, 0], [1969152327736, 0], [1969152294968, 0], [1969152262200, 0], [1969152229432, 0], [1969152196664, 0], [1969152163896, 0], [1969152131128, 0], [1969152098360, 0], [1927082967096, 0], [1927082934328, 0], [1927082541112, 0], [1927082344504, 0], [1974003040312, 0], [1974003007544, 0], [1974002974776, 0], [1974002942008, 0], [1974002909240, 0], [1974002876472, 0], [1974002843704, 0], [1974002778168, 0], [1974002745400, 0], [1974002712632, 0], [1974002679864, 0], [1974002647096, 0], [1974002581560, 0], [1974002548792, 0], [1974002516024, 0], [1972338589752, 0], [1972338556984, 0], [1972338524216, 0], [1972338491448, 0], [1972338458680, 0], [1972338425912, 0], [1972338393144, 0], [1972338360376, 0], [1972338327608, 0], [1972338294840, 0], [1972338262072, 0], [1972338229304, 0], [1972338196536, 0], [1972338163768, 0], [1972338131000, 0], [1972338098232, 0], [1972338065464, 0], [1972338032696, 0], [1972337999928, 0], [1972337967160, 0], [1972337934392, 0], [1972337901624, 0], [1972337868856, 0], [1972337836088, 0], [1972337803320, 0], [1972337770552, 0], [1972337737784, 0], [1972337705016, 0], [1972337672248, 0], [1972337639480, 0], [1972337606712, 0], [1972337573944, 0], [1972337541176, 0], [1972337508408, 0], [1972337475640, 0], [1972337442872, 0], [1972315750456, 0], [1972315717688, 0], [1972315586616, 0], [1972315553848, 0], [1972315488312, 0], [1972315455544, 0], [1972315422776, 0], [1972315357240, 0], [1972313063480, 0], [1972313030712, 0], [1972312899640, 0], [1972312866872, 0], [1972312801336, 0], [1972312768568, 0], [1972312735800, 0], [1972312670264, 0], [1972312408120, 0], [1972312375352, 0]]
irb(main):022:0> p.next_page?
irb(main):023:0> products.next_page?
=> true
irb(main):024:0> products.previous_page?
=> true
irb(main):025:0> products = products.fetch_previous_page
irb(main):028:0> products.map { |p| [p.id, p.variants.first.inventory_quantity] }
=> [[1927082278968, 300], [1927082836024, 300], [1927082803256, 300], [1927082770488, 300], [1927082311736, 300], [1931623825464, 900], [1927082410040, 300], [1927082377272, 300], [1927082606648, 300], [1927082573880, 300], [1974167830584, 500], [1931371839544, 500], [1927082868792, 300], [1927082704952, 300], [1927082672184, 300], [1927082639416, 300], [1927082508344, 300], [1927082475576, 300], [1927082442808, 300], [1974003073080, 200], [1972226621496, 200], [1931627724856, 200], [1931547148344, 200], [1931522900024, 200], [1931459657784, 200], [1928719499320, 200], [1927082737720, 100], [1972315390008, 9], [1972312703032, 9], [1972304904248, 9], [1972288913464, 9], [1972286685240, 9], [1972286128184, 9], [1972285472824, 9], [1972284915768, 9], [1972284194872, 9], [1972277870648, 9], [1972276789304, 9], [1972205191224, 45], [1972312047672, 9], [1972287275064, 9], [1972283473976, 9], [1972278493240, 9], [1933201047608, 9], [1933189218360, 9], [1933188661304, 9], [1933188104248, 9], [1933186924600, 9], [1974002614328, 20], [1972226162744, 20], [1931627233336, 20], [1931546689592, 20], [1931522441272, 20], [1931459002424, 20], [1927082901560, 15], [1972315783224, 1], [1972313096248, 1], [1972312440888, 1], [1972305428536, 1], [1972293304376, 1], [1972287668280, 1], [1972287078456, 1], [1972286521400, 1], [1972285866040, 1], [1972285308984, 1], [1972284588088, 1], [1972283867192, 1], [1972278886456, 1], [1972278263864, 1], [1972277182520, 1], [1970117509176, 1], [1970115805240, 1], [1970112856120, 1], [1928477507640, 5], [1928477474872, 5], [1928477442104, 5], [1928477409336, 5], [1928477376568, 5], [1928477343800, 5], [1928477311032, 5], [1928477278264, 5], [1928477245496, 5], [1974002810936, 5], [1972226359352, 5], [1931627429944, 5], [1931546886200, 5], [1931522637880, 5], [1931459297336, 5], [1972315684920, 1], [1972312997944, 1], [1972312342584, 1], [1972305297464, 1], [1972293173304, 1], [1972287569976, 1], [1972286980152, 1], [1972286423096, 1], [1972285767736, 1], [1972285210680, 1], [1972284489784, 1], [1972283768888, 1], [1972278788152, 1], [1972278165560, 1], [1972277084216, 1], [1930817372216, 2], [1930817142840, 3], [1930657955896, 2], [1930657726520, 3], [1930657693752, 2], [1930657464376, 3], [1930657431608, 2], [1930657202232, 3], [1930657169464, 2], [1930656940088, 3], [1930275192888, 2], [1930274963512, 3], [1929510551608, 2], [1929510158392, 3], [1929293398072, 2], [1929293168696, 3], [1929054486584, 2], [1929054257208, 3], [1929054224440, 2], [1929053995064, 3], [1929053798456, 2], [1929053569080, 3], [1929053470776, 2], [1929053241400, 3], [1929047736376, 2], [1929047507000, 3], [1929047408696, 2], [1929047179320, 3], [1929047146552, 2], [1929046917176, 3], [1929046884408, 2], [1929046655032, 3], [1929046589496, 2], [1929046360120, 3], [1929046229048, 2], [1929045999672, 3], [1928749350968, 2], [1928749121592, 3], [1928738734136, 2], [1928738504760, 3], [1928738275384, 2], [1928738046008, 3], [1928726315064, 2], [1928726052920, 3], [1928725135416, 2], [1928724873272, 3], [1928723038264, 2], [1928722808888, 3], [1928722448440, 2], [1928722186296, 3], [1928721596472, 2], [1928721334328, 3], [1928720973880, 2], [1928720744504, 3], [1928720547896, 2], [1928720318520, 3], [1928719958072, 2], [1928719695928, 3], [1928719532088, 2], [1928719269944, 3], [1928719040568, 2], [1928718811192, 3], [1928704753720, 2], [1928704491576, 3], [1928690106424, 2], [1928689844280, 3], [1930817339448, 2], [1930817306680, 2], [1930657923128, 2], [1930657890360, 2], [1930657660984, 2], [1930657628216, 2], [1930657398840, 2], [1930657366072, 2], [1930657136696, 2], [1930657103928, 2], [1930275160120, 2], [1930275127352, 2], [1929510486072, 2], [1929510420536, 2], [1929293365304, 2], [1929293332536, 2], [1929054453816, 2], [1929054421048, 2], [1929054191672, 2], [1929054158904, 2], [1929053765688, 2], [1929053732920, 2], [1929053438008, 2], [1929053405240, 2], [1929047703608, 2], [1929047670840, 2], [1929047375928, 2], [1929047343160, 2], [1929047113784, 2], [1929047081016, 2], [1929046851640, 2], [1929046818872, 2], [1929046556728, 2], [1929046523960, 2], [1929046196280, 2], [1929046163512, 2], [1928749318200, 2], [1928749285432, 2], [1928738701368, 2], [1928738668600, 2], [1928738242616, 2], [1928738209848, 2], [1928726282296, 2], [1928726216760, 2], [1928725102648, 2], [1928725069880, 2], [1928723005496, 2], [1928722972728, 2], [1928722415672, 2], [1928722382904, 2], [1928721563704, 2], [1928721498168, 2], [1928720941112, 2], [1928720908344, 2], [1928720515128, 2], [1928720482360, 2], [1928719925304, 2], [1928719859768, 2], [1928719466552, 2], [1928719007800, 2], [1928718975032, 2], [1928704720952, 2], [1928704655416, 2], [1928690073656, 2], [1928690040888, 2], [1972315815992, 1], [1972315652152, 1], [1972315619384, 1], [1972315521080, 1], [1972315324472, 1], [1972315291704, 1], [1972313129016, 1], [1972312965176, 1], [1972312932408, 1], [1972312834104, 1], [1972312637496, 1], [1972312604728, 1], [1972312473656, 1], [1972312309816, 1], [1972312277048, 1], [1972312178744, 1]]
irb(main):029:0>

Products with fields, limit, order

irb(main):030:0> products = ShopifyAPI::Product.find(:all, params: { order: 'inventory_total desc', fields:'id,created_at', limit: 10 })
=> [#<ShopifyAPI::Product:0x00007febccb91418 @attributes={"id"=>1927082278968, "created_at"=>"2019-02-14T15:00:43-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb91080 @attributes={"id"=>1927082836024, "created_at"=>"2019-02-14T15:00:57-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb90d10 @attributes={"id"=>1927082803256, "created_at"=>"2019-02-14T15:00:56-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb90a18 @attributes={"id"=>1927082770488, "created_at"=>"2019-02-14T15:00:54-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb90630 @attributes={"id"=>1927082311736, "created_at"=>"2019-02-14T15:00:44-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb901d0 @attributes={"id"=>1931623825464, "created_at"=>"2019-04-08T12:02:09-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb83d90 @attributes={"id"=>1927082410040, "created_at"=>"2019-02-14T15:00:46-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb83a20 @attributes={"id"=>1927082377272, "created_at"=>"2019-02-14T15:00:45-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb83660 @attributes={"id"=>1927082606648, "created_at"=>"2019-02-14T15:00:51-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb832a0 @attributes={"id"=>1927082573880, "created_at"=>"2019-02-14T15:00:50-06:00"}, @prefix_options={}, @persisted=true>]

irb(main):031:0> products = products.fetch_next_page
=> [#<ShopifyAPI::Product:0x00007febccb008c8 @attributes={"id"=>1974167830584, "created_at"=>"2019-06-26T20:10:56-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb005f8 @attributes={"id"=>1931371839544, "created_at"=>"2019-04-03T20:10:46-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccb00210 @attributes={"id"=>1927082868792, "created_at"=>"2019-02-14T15:00:58-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf3ee8 @attributes={"id"=>1927082704952, "created_at"=>"2019-02-14T15:00:52-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf3a88 @attributes={"id"=>1927082672184, "created_at"=>"2019-02-14T15:00:52-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf3740 @attributes={"id"=>1927082639416, "created_at"=>"2019-02-14T15:00:51-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf3308 @attributes={"id"=>1927082508344, "created_at"=>"2019-02-14T15:00:49-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf2de0 @attributes={"id"=>1927082475576, "created_at"=>"2019-02-14T15:00:48-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf2a48 @attributes={"id"=>1927082442808, "created_at"=>"2019-02-14T15:00:48-06:00"}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Product:0x00007febccaf25c0 @attributes={"id"=>1974003073080, "created_at"=>"2019-06-25T10:49:37-06:00"}, @prefix_options={}, @persisted=true>]
irb(m

Orders (not converted yet)

orders = ShopifyAPI::Order.find(:all, params: { order: 'created_at  desc', limit: 50 })
irb(main):011:0> orders.map(&:created_at)
=> ["2019-06-12T10:38:39-06:00", "2019-06-12T10:38:36-06:00", "2019-06-12T10:38:34-06:00", "2019-06-12T10:38:31-06:00", "2019-06-12T10:38:30-06:00", "2019-06-12T10:38:28-06:00", "2019-06-12T10:38:27-06:00", "2019-06-12T10:38:26-06:00", "2019-06-12T10:38:24-06:00", "2019-06-12T10:38:21-06:00", "2019-06-12T10:38:20-06:00", "2019-06-12T10:38:19-06:00", "2019-06-12T10:38:17-06:00", "2019-06-12T10:38:16-06:00", "2019-06-12T10:38:14-06:00", "2019-06-12T10:38:13-06:00", "2019-06-12T10:38:11-06:00", "2019-06-12T10:38:10-06:00", "2019-06-12T10:38:08-06:00", "2019-06-12T10:38:06-06:00", "2019-06-12T10:38:05-06:00", "2019-06-12T10:38:02-06:00", "2019-06-12T10:38:00-06:00", "2019-06-12T10:37:59-06:00", "2019-06-12T10:37:57-06:00", "2019-06-12T10:37:56-06:00", "2019-06-12T10:37:54-06:00", "2019-06-12T10:37:52-06:00", "2019-06-12T10:37:50-06:00", "2019-06-12T10:37:49-06:00", "2019-06-12T10:37:47-06:00", "2019-06-12T10:37:45-06:00", "2019-06-12T10:37:44-06:00", "2019-06-12T10:37:42-06:00", "2019-06-12T10:37:41-06:00", "2019-06-12T10:37:39-06:00", "2019-06-12T10:37:38-06:00", "2019-06-12T10:37:36-06:00", "2019-06-12T10:37:35-06:00", "2019-06-12T10:37:33-06:00", "2019-06-12T10:37:32-06:00", "2019-06-12T10:37:30-06:00", "2019-06-12T10:37:28-06:00", "2019-06-12T10:37:26-06:00", "2019-06-12T10:37:24-06:00", "2019-06-12T10:37:23-06:00", "2019-06-12T10:37:22-06:00", "2019-06-12T10:37:20-06:00", "2019-06-12T10:37:19-06:00", "2019-06-12T10:37:17-06:00"]
irb(main):012:0> orders.next_page?
=> false
irb(main):013:0> orders.count
=> 50

Events with filter

irb(main):014:0> events = ShopifyAPI::Event.find(:all, params: { order: 'created_at  desc', limit: 5, filter: 'Collection' })
irb(main):015:0> events.count
=> 5
irb(main):017:0> events.map(&:subject_type)
=> ["Collection", "Collection", "Collection", "Collection", "Collection"]
irb(main):018:0> events = events.fetch_next_page
irb(main):019:0> events.map{ |e| [e.id, e.subject_type])
=> [[59028163214, "Collection"], [59286913742, "Collection"], [60342328142, "Collection"], [62446756366, "Collection"], [66334720206, "Collection"]]
irb(main):021:0> events = events.fetch_previous_page
irb(main):022:0> events.map{ |e| [e.id, e.subject_type]}
=> [[56126021646, "Collection"], [56126765710, "Collection"], [56126809038, "Collection"], [56339695502, "Collection"], [56339735182, "Collection"]]
irb(main):023:0> events = events.fetch_next_page
irb(main):024:0> events.map{ |e| [e.id, e.subject_type]}
=> [[59028163214, "Collection"], [59286913742, "Collection"], [60342328142, "Collection"], [62446756366, "Collection"], [66334720206, "Collection"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment