Skip to content

Instantly share code, notes, and snippets.

@tsnow
Created January 11, 2011 18:52
Show Gist options
  • Save tsnow/774907 to your computer and use it in GitHub Desktop.
Save tsnow/774907 to your computer and use it in GitHub Desktop.
##The original processing done by this protoperk. (From rbs_hrz.sql)
ruby-1.8.7-p302 > puts ProtoPerk.find(324076).stdout
ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391}
finding 0 locations for ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391} (324076)
Processing tbds: christmas sale
locs benefit applies_to type reward_fixed dollars_off min_overall reward_var free_shipping per_n_dollars store_id reward_multi free_gift unrestricted min_dollars program_id reduced_shipping percent_off
updated: Coupon(249980,289207,315750)
Status: updated
# Note the:
# locs benefit applies_to type reward_fixed dollars_off min_overall
# reward_var free_shipping per_n_dollars store_id reward_multi free_gift
# unrestricted min_dollars program_id reduced_shipping percent_off
# That tells which fields the updated deals were matched on.
# The bug described in Mystery #2 is a result of my accidentally not making :code be in that list.
## All ICE.com deals, by scraper
ruby-1.8.7-p302 > puts Store.find(1176).deals.scoped(:conditions => {:type => 'Coupon'}).map{|d| "#{d.scraper_id}, #{d.code}, #{d.id}, #{d.echo}"}
77, , 70691, ICE.com 20% off at ICE.com {1006619}
64, SSMOM, 249980, ICE.com 20% off jewelry at ICE.com {187391}
64, SCPMN, 289207, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
64, , 294783, ICE.com Free Pearl Bracelet with purchase at Ice.com {163380}
77, SEM21, 312467, ICE.com 20% off Amethyst Gold Rings under $400 at ICE.com {407111}
77, SEM22, 312469, ICE.com 20% off Diamond Anniversary Rings at ICE.com {407112}
77, SEM23, 312470, ICE.com 20% off Diamond Tennis Bracelets at ICE.com {407113}
77, SEM24, 312472, ICE.com 20% off Blue Topaz Gold Rings under $400 at ICE.com {407114}
77, SMR09, 312473, ICE.com 20% off all Jewelry at ICE.com {450111}
64, S1SHP, 315121, ICE.com Reduced Shipping + 20% off at Ice.com {163381}
64, S10FL, 315750, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
64, , 321322, ICE.com Enjoy 62% Savings on this.5 Carat Diamond 14K White Gold Solitaire Studs - Only $375 {184801}
64, , 321323, ICE.com Enjoy 66% Savings on this 5.14 Carat Blue & White Topaz Sterling Silver Ring - Only $65! {184800}
64, , 321324, ICE.com Enjoy 64% Savings on this 3.5 Carat Blue Topaz and Diamond 14K White Gold Ring - Only $215! {184799}
64, , 321325, ICE.com Enjoy 62% Savings on this.5 Carat Black Diamond 14K White Gold Ring w Black Rhodium - Only $225! {184798}
64, , 321326, ICE.com Enjoy 62% Savings on this 12.14 Carat Blue Topaz Sterling Silver Ring - Only $75! {184797}
64, , 321327, ICE.com Enjoy 66% Savings on this.125 Carat Diamond Pink & Yellow Gold Over Sterling Silver Pendant - Only $65! {184796}
64, , 321328, ICE.com Enjoy 66% Savings on this 2.25 Carat Amethyst Sterling Silver Earrings - Only $65! {184795}
64, , 321329, ICE.com Enjoy 64% Savings on this 2.62 Carat Tanzanite Sterling Silver Bracelet - Only $70! {184794}
63, SJAN1, 339959, ICE.com 20% off at Ice.com {94772}
##Fmtc protoperks
ruby-1.8.7-p302 > puts Scraper.find(77).proto_perks.select{|x| x.rname =~ /ICE/}.map{|x| "#{x.scraper_id},#{x.code},#{x.id},#{x.echo}"}
77,SEM21,332186,ICE.com - Extra 20% off Amethyst Gold Rings under $400 at ICE.com (2012-12-31) {407111}
77,SEM22,332187,ICE.com - Extra 20% off Diamond Anniversary Rings at ICE.com (2012-12-31) {407112}
77,SEM23,332188,ICE.com - Extra 20% off Diamond Tennis Bracelets at ICE.com (2012-12-31) {407113}
77,SEM24,332189,ICE.com - Extra 20% off Blue Topaz Gold Rings under $400 at ICE.com (2012-12-31) {407114}
77,SMR09,332190,ICE.com - Extra 20% off all Jewelry at ICE.com (2012-12-31) {450111}
77,,332191,ICE.com - 20% off any order through this link at ICE.com (2011-01-17) {1006619}
##Secretprices protoperks
ruby-1.8.7-p302 > puts Scraper.find(64).proto_perks.select{|x| x.rname =~ /ICE/}.map{|x| "#{x.scraper_id},#{x.code},#{x.id},#{x.echo}"}
64,,323841,ICE.com - After Christmas Sale - additional 20% off jewelry at Ice.com (2011-01-17) {187901}
64,,324076,ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391}
64,,324508,ICE.com - Enjoy 62% Savings on this .5 Carat Diamond 14K White Gold Solitaire Studs - Only $375 (2011-01-31) {184801}
64,,324509,ICE.com - Enjoy 66% Savings on this 5.14 Carat Blue & White Topaz Sterling Silver Ring - Only $65! (2011-01-31) {184800}
64,,324510,ICE.com - Enjoy 64% Savings on this 3.5 Carat Blue Topaz and Diamond 14K White Gold Ring - Only $215! (2011-01-31) {184799}
64,,324511,ICE.com - Enjoy 62% Savings on this .5 Carat Black Diamond 14K White Gold Ring w Black Rhodium - Only $225! (2011-01-31) {184798}
64,,324512,ICE.com - Enjoy 62% Savings on this 12.14 Carat Blue Topaz Sterling Silver Ring - Only $75! (2011-01-31) {184797}
64,,324513,ICE.com - Enjoy 66% Savings on this .125 Carat Diamond Pink & Yellow Gold Over Sterling Silver Pendant - Only $65! (2011-01-31) {184796}
64,,324514,ICE.com - Enjoy 66% Savings on this 2.25 Carat Amethyst Sterling Silver Earrings - Only $65! (2011-01-31) {184795}
64,,324515,ICE.com - Enjoy 64% Savings on this 2.62 Carat Tanzanite Sterling Silver Bracelet - Only $70! (2011-01-31) {184794}
64,S1SHP,325237,ICE.com - $1 Shipping + 20% off site wide at Ice.com () {163381}
64,,325238,ICE.com - Free Pearl Bracelet with every purchase at Ice.com () {163380}
64,SSMOM,326446,ICE.com - Save 20% site wide on all jewelry at ICE.com () {123603}
## Secretprices protoperks with their connected deals
ruby-1.8.7-p302 > puts Scraper.find(64).proto_perks.select{|x| x.rname =~ /ICE/}.map{|x| deals_list = x.deals.map{|d| " - #{d.scraper_id}, #{d.code}, #{d.id}, #{d.echo}"}; "#{x.scraper_id},#{x.code},#{x.id},#{x.echo}\n#{deals_list.join(%(\n))}"}
64,,323841,ICE.com - After Christmas Sale - additional 20% off jewelry at Ice.com (2011-01-17) {187901}
64,,324076,ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391}
- 64, SCPMN, 289207, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
- 64, S10FL, 315750, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
64,,324508,ICE.com - Enjoy 62% Savings on this .5 Carat Diamond 14K White Gold Solitaire Studs - Only $375 (2011-01-31) {184801}
- 64, , 321322, ICE.com Enjoy 62% Savings on this.5 Carat Diamond 14K White Gold Solitaire Studs - Only $375 {184801}
64,,324509,ICE.com - Enjoy 66% Savings on this 5.14 Carat Blue & White Topaz Sterling Silver Ring - Only $65! (2011-01-31) {184800}
- 64, , 321323, ICE.com Enjoy 66% Savings on this 5.14 Carat Blue & White Topaz Sterling Silver Ring - Only $65! {184800}
64,,324510,ICE.com - Enjoy 64% Savings on this 3.5 Carat Blue Topaz and Diamond 14K White Gold Ring - Only $215! (2011-01-31) {184799}
- 64, , 321324, ICE.com Enjoy 64% Savings on this 3.5 Carat Blue Topaz and Diamond 14K White Gold Ring - Only $215! {184799}
64,,324511,ICE.com - Enjoy 62% Savings on this .5 Carat Black Diamond 14K White Gold Ring w Black Rhodium - Only $225! (2011-01-31) {184798}
- 64, , 321325, ICE.com Enjoy 62% Savings on this.5 Carat Black Diamond 14K White Gold Ring w Black Rhodium - Only $225! {184798}
64,,324512,ICE.com - Enjoy 62% Savings on this 12.14 Carat Blue Topaz Sterling Silver Ring - Only $75! (2011-01-31) {184797}
- 64, , 321326, ICE.com Enjoy 62% Savings on this 12.14 Carat Blue Topaz Sterling Silver Ring - Only $75! {184797}
64,,324513,ICE.com - Enjoy 66% Savings on this .125 Carat Diamond Pink & Yellow Gold Over Sterling Silver Pendant - Only $65! (2011-01-31) {184796}
- 64, , 321327, ICE.com Enjoy 66% Savings on this.125 Carat Diamond Pink & Yellow Gold Over Sterling Silver Pendant - Only $65! {184796}
64,,324514,ICE.com - Enjoy 66% Savings on this 2.25 Carat Amethyst Sterling Silver Earrings - Only $65! (2011-01-31) {184795}
- 64, , 321328, ICE.com Enjoy 66% Savings on this 2.25 Carat Amethyst Sterling Silver Earrings - Only $65! {184795}
64,,324515,ICE.com - Enjoy 64% Savings on this 2.62 Carat Tanzanite Sterling Silver Bracelet - Only $70! (2011-01-31) {184794}
- 64, , 321329, ICE.com Enjoy 64% Savings on this 2.62 Carat Tanzanite Sterling Silver Bracelet - Only $70! {184794}
64,S1SHP,325237,ICE.com - $1 Shipping + 20% off site wide at Ice.com () {163381}
- 64, S1SHP, 315121, ICE.com Reduced Shipping + 20% off at Ice.com {163381}
64,,325238,ICE.com - Free Pearl Bracelet with every purchase at Ice.com () {163380}
- 64, , 294783, ICE.com Free Pearl Bracelet with purchase at Ice.com {163380}
64,SSMOM,326446,ICE.com - Save 20% site wide on all jewelry at ICE.com () {123603}
- 64, SSMOM, 249980, ICE.com 20% off jewelry at ICE.com {187391}
##Fmtc protoperks with their connected deals
77,SEM21,332186,ICE.com - Extra 20% off Amethyst Gold Rings under $400 at ICE.com (2012-12-31) {407111}
- 77, SEM21, 312467, ICE.com 20% off Amethyst Gold Rings under $400 at ICE.com {407111}
77,SEM22,332187,ICE.com - Extra 20% off Diamond Anniversary Rings at ICE.com (2012-12-31) {407112}
- 77, SEM22, 312469, ICE.com 20% off Diamond Anniversary Rings at ICE.com {407112}
77,SEM23,332188,ICE.com - Extra 20% off Diamond Tennis Bracelets at ICE.com (2012-12-31) {407113}
- 77, SEM23, 312470, ICE.com 20% off Diamond Tennis Bracelets at ICE.com {407113}
77,SEM24,332189,ICE.com - Extra 20% off Blue Topaz Gold Rings under $400 at ICE.com (2012-12-31) {407114}
- 77, SEM24, 312472, ICE.com 20% off Blue Topaz Gold Rings under $400 at ICE.com {407114}
77,SMR09,332190,ICE.com - Extra 20% off all Jewelry at ICE.com (2012-12-31) {450111}
- 77, SMR09, 312473, ICE.com 20% off all Jewelry at ICE.com {450111}
77,,332191,ICE.com - 20% off any order through this link at ICE.com (2011-01-17) {1006619}
- 77, , 70691, ICE.com 20% off at ICE.com {1006619}
##Reprocessing the errant proto results in grabbing those same deals, even with the updated code which handles :code
# because the deals' old siteids have been replaced with that of the incoming proto_perk in question.
ruby-1.8.7-p302 > ProtoPerk.find(324076).process(true)
=> {:update_programs=>[], :update_stores=>[], :updated_ids=>[249980, 289207, 315750], :expired_ids=>[], :created_ids=>[]}
ruby-1.8.7-p302 > puts Deal.find(_[:updated_ids]).map{|d| "#{d.scraper_id}, #{d.code}, #{d.id}, #{d.echo}"}
64, SSMOM, 249980, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
64, SCPMN, 289207, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
64, S10FL, 315750, ICE.com After Christmas Sale - Save 20% at Ice.com {187391}
ruby-1.8.7-p302 > puts ProtoPerk.find(324076).stdout
ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391}
finding 0 locations for ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391} (324076)
scraper and siteid
updated: Coupon(249980,289207,315750)
Status: updated
=> nil
#Applies_to's for those deals, showing how they were able to be faultily matched.
Deal.find(249980,289207,315750).map{|x| x.applies_to}
=> [[], [], []]
ruby-1.8.7-p302 > puts ProtoPerk.find(326446).stdout
ICE.com - Save 20% site wide on all jewelry at ICE.com () {123603}
finding 0 locations for ICE.com - Save 20% site wide on all jewelry at ICE.com () {123603} (326446)
Processing tbds: jewelry
locs benefit applies_to type reward_fixed dollars_off code min_overall reward_var free_shipping per_n_dollars store_id reward_multi free_gift unrestricted min_dollars program_id reduced_shipping percent_off
Coupon data differs, but not changing because incoming Unknown <=> 2011-01-17
updated: Coupon(249980)
Status: updated
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment