Skip to content

Instantly share code, notes, and snippets.

@jesus-lerma

jesus-lerma/r.rb Secret

Last active October 12, 2023 16:38
Show Gist options
  • Save jesus-lerma/d317555de8cccb0e81fbaa801f65d63e to your computer and use it in GitHub Desktop.
Save jesus-lerma/d317555de8cccb0e81fbaa801f65d63e to your computer and use it in GitHub Desktop.
I used this script to map the staging base env for bi clusters.
def create_scenario
mx_hour = Time.use_zone('America/Mexico_City') do
tz=Time.zone.now
(tz - tz.round(0).sec.seconds)
end
event=AuctionEvent.create(
name: "Auction Autocom",
status: :scheduled,
starts_at: mx_hour + 2.minutes,
ends_at: mx_hour + 3.minutes
)
ids = [
8617,
8616,
7500,
7672,
7435,
8614,
8613,
8612
]
vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
vehicles.each do |vehicle|
Auction.create(
status: :pending,
vehicle: vehicle,
auction_event: event,
min_bid: vehicle.price
)
end
end
# Primer Sección
class Api::V3::ContactNumbersController < ApplicationController
def create
..
Refund.create
RefundTeam.notify
Charge.create_negative_charge
Client.notify
...
end
end
# Segunda Sección
class Api::V3::ContactNumbersController < ApplicationController
def create
..
Refund.create_refund
...
end
end
class Refund < ApplicationRecord
def create_refund
create
RefundTeam.notify
Charge.create_negative_charge
Client.notify
end
end
# Tercer Seccion
class Api::V3::ContactNumbersController < ApplicationController
def create
..
RefundService.new.call
...
end
end
class RefundService < ApplicationRecord
def call
Refund.create
RefundTeam.notify
Charge.create_negative_charge
Client.notify
end
end
@jesus-lerma
Copy link
Author

QA For creatio vehicles

def create_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Autocom",
    status: :scheduled,
    starts_at: mx_hour + 2.minutes,
    ends_at: mx_hour + 5.minutes
  )
  ids = [
    4044, 3692, 3690
  ]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

@jesus-lerma
Copy link
Author

jesus-lerma commented Sep 14, 2023

QA Prod for creatio vehicles with three hours.

def create_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Autocom",
    status: :scheduled,
    starts_at: mx_hour + 2.minutes,
    ends_at: mx_hour + 6.hours
  )
  ids = [
    4044, 3692, 3690
  ]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

@jesus-lerma
Copy link
Author

jesus-lerma commented Oct 2, 2023

Vehículos Autocom

def create_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Autocom",
    status: :scheduled,
    starts_at: mx_hour + 2.minutes,
    ends_at: mx_hour + 6.hours
  )
  ids = [
    4388, 284, 4389
  ]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

@jesus-lerma
Copy link
Author

Honda CRV abierta

def create_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Event Script",
    status: :scheduled,
    starts_at: mx_hour + 1.minutes,
    ends_at: mx_hour + 10.minutes
  )
  ids = [4469]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

@jesus-lerma
Copy link
Author

jesus-lerma commented Oct 10, 2023

def create_open_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Event Script",
    status: :scheduled,
    starts_at: mx_hour + 1.minutes,
    ends_at: mx_hour + 3.minutes
  )
  ids = [4469,  4436, 4470]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end
def create_scheduled_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Auction Event Script",
    status: :scheduled,
    starts_at: mx_hour + 2.hours,
    ends_at: mx_hour + 3.hours
  )
  ids = [4390, 473, 428, 545, 390, 4413]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

@jesus-lerma
Copy link
Author

def create_open_scenario
  mx_hour = Time.use_zone('America/Mexico_City') do
    tz=Time.zone.now
    (tz - tz.round(0).sec.seconds)
  end

  event=AuctionEvent.create(
    name: "Autocom Event Script",
    status: :scheduled,
    starts_at: mx_hour + 1.minutes,
    ends_at: mx_hour + 3.minutes
  )
  ids = [4388]
  vehicles = Vehicle.where(id: VehicleInspection.where(id: ids).pluck(:vehicle_id))
  vehicles.each do |vehicle|
    Auction.create(
      status: :pending,
      vehicle: vehicle,
      auction_event: event,
      min_bid: vehicle.price
    )
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment