Skip to content

Commit

Permalink
feat: add more fields on ranking spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
mewthu2 committed Apr 16, 2024
1 parent 0581cd5 commit b5363dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/jobs/product_ranking_spreadsheet_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def perform(year)

header = ['Product Name',
'SKU',
'Fulfillment Channel',
'ASIN1',
'January',
'February',
'March',
Expand All @@ -25,17 +27,21 @@ def perform(year)
'November',
'December']

header.each_with_index { |data, row| tab.add_cell(0, row, data) }
header.each_with_index { |data, col| tab.add_cell(0, col, data) }

row_index = 1

product_sales.each_value do |sales|
product = sales.first.product
tab.add_cell(row_index, 0, product.item_name)
tab.add_cell(row_index, 1, product.seller_sku)
tab.add_cell(row_index, 2, product.fulfillment_channel)
tab.add_cell(row_index, 3, product.asin1)

month_columns = { 'January' => 4, 'February' => 5, 'March' => 6, 'April' => 7, 'May' => 8, 'June' => 9, 'July' => 10, 'August' => 11, 'September' => 12, 'October' => 13, 'November' => 14, 'December' => 15 }

sales.each do |sale|
month_index = Date::MONTHNAMES.index(sale.month_refference)
month_index = month_columns[sale.month_refference]
tab.add_cell(row_index, month_index, sale.unit_count)
end

Expand Down

0 comments on commit b5363dd

Please sign in to comment.