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
| require 'net/http' | |
| require 'thread' | |
| require 'thwait' | |
| class LoaderIoWorker | |
| BASE_URL = 'https://api.loader.io/v2' | |
| APP_ID = 'xxx' | |
| AUTH_KEY = 'yyy' | |
| AUTH_HEADER = {'loaderio-auth' => AUTH_KEY} | |
| MAX_RETRIES = 10 | |
| attr_accessor :domain, :tests |
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
| start_date = DateTime.new(2019, 5, 22, 8, 59, 0).utc #change date to start of error | |
| os = Order.unscoped.where("created_at > ?", start_date).includes(:order_items) | |
| os.map do |o| | |
| o.order_items.map do |oi| | |
| if oi.options_ar.present? | |
| begin | |
| JSON.parse(oi.options_ar) | |
| rescue | |
| oi.update_attributes(options_ar: eval(oi.options_ar)) | |
| JSON.parse(oi.options_ar) |
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
| include ExceptionForMatrix | |
| def and_matrices(mx1, mx2) | |
| Matrix.Raise ErrDimensionMismatch, "Matrix dimension mismatch" unless (mx1.row_count == mx2.row_count && mx1.column_count == mx2.column_count) | |
| arr = Array.new(mx1.row_count){Array.new(mx1.column_count)} | |
| mx1.each_with_index{ |elem, ix, iy| arr[ix][iy] = (elem && mx2.element(ix,iy)) } | |
| Matrix.rows(arr) | |
| end |
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
| BRAND_RATING_FACTOR = {:high => 1.1, :low => 0.9} | |
| PRICING_REFRENCE = {15 => 0.75, 25 => 0.775, 50 => 0.8, 75 => 0.825, 100 => 0.85, 200 => 0.875, 400 => 0.9, 600 => 0.925} | |
| price_reference = 99 | |
| product_database_shipping_cost = 50 | |
| brand_rating = 'high' | |
| def get_pricing_ceil(price) | |
| PRICING_REFRENCE.find {|key, _| price < key}.try(:last) || 0.95 | |
| end |