Skip to content

Commit

Permalink
fix: now months can read correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mewthu2 committed Apr 16, 2024
1 parent b5363dd commit b6e331b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 0 additions & 6 deletions app/jobs/search_order_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ def perform(order_kind, next_token, specific_order)
end
end

def aaa
Product.where(fulfillment_channel: 'FBA').each do |prod|
Product.find_by(fulfillment_channel: 'FBM', id_product: prod.id_product)&.update_columns(supplier_url: prod.supplier_url)
end
end

def search(order_kind, next_token)
created_after_date = '2023-12-10'

Expand Down
14 changes: 7 additions & 7 deletions app/jobs/update_product_sales_job.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
class UpdateProductSalesJob < ActiveJob::Base
def perform(kind)
def perform(kind, month)
@access_token = obtain_acess_token

update_product_sales_info(kind)
update_product_sales_info(kind, month)
end

def update_product_sales_info(kind)
def update_product_sales_info(kind, month)
case kind
when 'thirty_days'
update_thirty_days_sales(kind)
update_thirty_days_sales(kind, month)
end
end

def update_thirty_days_sales(kind)
def update_thirty_days_sales(kind, month)
products = Product.where(status: 'Active')

data_refference = Date.today.prev_month
data_refference = month.present? ? Date.new(Date.today.year, month, 1) : Date.today.prev_month

start_date = data_refference.beginning_of_month.strftime('%Y-%m-%dT00:00:00Z')
end_date = data_refference.strftime('%Y-%m-%dT%H:%M:%SZ')
end_date = data_refference.end_of_month.strftime('%Y-%m-%dT%H:%M:%SZ')
date_range = "#{start_date}--#{end_date}"

products.each do |prd|
Expand Down

0 comments on commit b6e331b

Please sign in to comment.