Skip to content

Instantly share code, notes, and snippets.

@alkema
Last active December 15, 2015 03:21
Show Gist options
  • Save alkema/c27ef1603607608c00e2 to your computer and use it in GitHub Desktop.
Save alkema/c27ef1603607608c00e2 to your computer and use it in GitHub Desktop.
irb(main):004:0> reload!; puts MerchantDirectory::Activity.fully_provisionable.count
Reloading...
(265.5ms) SELECT DISTINCT COUNT(DISTINCT `merchant_directory_activities`.`id`) FROM `merchant_directory_activities` INNER JOIN merchant_directory_variants ON merchant_directory_variants.merchant_activity_id = merchant_directory_activities.id INNER JOIN merchant_directory_availability_rules ON merchant_directory_availability_rules.merchant_variant_id = merchant_directory_variants.id WHERE (merchant_directory_activities.confero_id IS NOT NULL) AND (merchant_directory_variants.price IS NOT NULL) AND (merchant_directory_variants.duration < 86400) AND (merchant_directory_availability_rules.start_date is not NULL) AND (merchant_directory_availability_rules.end_date is not NULL) AND (merchant_directory_availability_rules.valid_days != '[]') AND (merchant_directory_availability_rules.start_time is not null)
9655
irb(main):005:0> MerchantDirectory::Variant.where('merchant_directory_variants.duration > 86400').update_all(duration: 4500)
SQL (18.4ms) UPDATE `merchant_directory_variants` SET `duration` = 4500 WHERE (merchant_directory_variants.duration > 86400)
=> 2283
irb(main):006:0> MerchantDirectory::Variant.where('merchant_directory_variants.price IS NULL OR price = 0').update_all(price: 45)
SQL (59.5ms) UPDATE `merchant_directory_variants` SET `price` = 45 WHERE (merchant_directory_variants.price IS NULL OR price = 0)
=> 3079
irb(main):007:0> reload!; puts MerchantDirectory::Activity.fully_provisionable.count
Reloading...
(256.9ms) SELECT DISTINCT COUNT(DISTINCT `merchant_directory_activities`.`id`) FROM `merchant_directory_activities` INNER JOIN merchant_directory_variants ON merchant_directory_variants.merchant_activity_id = merchant_directory_activities.id INNER JOIN merchant_directory_availability_rules ON merchant_directory_availability_rules.merchant_variant_id = merchant_directory_variants.id WHERE (merchant_directory_activities.confero_id IS NOT NULL) AND (merchant_directory_variants.price IS NOT NULL) AND (merchant_directory_variants.duration < 86400) AND (merchant_directory_availability_rules.start_date is not NULL) AND (merchant_directory_availability_rules.end_date is not NULL) AND (merchant_directory_availability_rules.valid_days != '[]') AND (merchant_directory_availability_rules.start_time is not null)
12787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment