Skip to content

Instantly share code, notes, and snippets.

@jdwolk
Last active December 16, 2016 20:01
Show Gist options
  • Save jdwolk/1b4ec0e898d5ba3772861d63cfb911c2 to your computer and use it in GitHub Desktop.
Save jdwolk/1b4ec0e898d5ba3772861d63cfb911c2 to your computer and use it in GitHub Desktop.
FC Beluga Status Notes

Statuses Digging

Sold

app/api/api/me/shoes.rb

  • GET /:id/sales
    • query based on #sold_at

app/api/api/v1/stock_items.rb

  • POST /api/stock_items/serialized/:serialized_id/sold

    • sold_at is param
    • passed into stock_item.sell!
  • POST /api/stock_items/fcu/:fc_upc/sold

    • sold_at is param
    • CAN BE DELETED

app/controllers/products_controller.rb

  • #product_inventory

    • query for product.stock_items with sold: false
  • #product_sales_history

    • using product.sold_stock_items

app/controllers/users_controller.rb

  • helper_method :sold_stock_items
    • user.stock_items.sold
    • query based on #sold_at

app/decorators/stock_item_decorator.rb

  • #sold_at -> stock_item.sold_at

app/entities/sell_product_entity.rb

  • expose #sold_at

app/entities/shoe_detail_entity.rb

  • #sizes_with_owned_count
    • user.portfolio_items.unsold
    • query for stock items where('sold_at ...')

app/entities/sold_item_entity.rb

  • expose sold_at
  • expose sold_price_cents
  • expose income
    • record.sold_price_cents

app/entitites/stock_item_decorator.rb

  • export sold (2x; 1 can be deleted)
  • export sold_at

app/helpers/location_helper

  • #move_to_sold
    • External API calls

app/models/invoice_line_item.rb

  • #create_ledger!
    • stock_item.sold! + sold_at

app/models/product.rb

  • #bestsellers

    • query based on stock_items.sold + sold_at
  • #highest_grossing

    • query based on stock_items.sold + sold_at
  • #average_age_days

    • stock_items.sold + sold_stock_items
  • #sold_stock_items

    • stock_items.where(sold: true).reorder(sold_at: :desc)

app/models/shoe.rb

  • #selling_volume
    • bestseller.stock_items.sold.where(sold_at
    • stock_items.sold.where(sold_at

app/models/stock_item.rb

  • scope :sold (based on sold and sold_at

  • scope :in_stock

    • sold: false, hidden: false.where withdrawn is false or null
  • scope :hidden

    • where(hidden: true, sold: false, withdrawn: false)
  • scope :sold_today

    • where(sold_at
  • #sold!

    • sold_at
    • mark_as_sold!(sold_at)
    • save!
  • #sell!

    • sold!(sold_at
  • #mark_as_sold!

    • sold=true
    • sold_at
    • save!
  • .sold_yesterday

    • where(sold_at:
  • #age_in_secs

    • sold + sold_at
  • #shelf_life_days

    • sold_at
  • #status

    • sold?
  • #editable?

    • sold? || withdrawn?

app/models/user.rb

  • .with_sales

    • stock_items.where(stock_items.sold).where(sold_at
  • #order_available_stock_items_by_age

    • select(sold_at

app/models/variant.rb

  • #last_sale

    • stock_items.sold.order(sold_at
  • #first_sale

    • sold.order(sold_at
  • #sold!

    • stock_item.sold!

app/services/consigned_stock/status_changed_email_facade.rb

  • Event type (probably ignorable)

app/views/products/_sales_history_tab.html.erb

  • item.sold_at (could refactor how its formatting)

app/views/products/show.html.erb

  • product.sold_stock_items

app/views/users/_sales_history.html.erb

  • stock_item.sold_at

app/views/users/show.html.erb

  • sold_stock_items (check controller)

app/workers/magento_shipping_worker.rb

  • #perform
    • stock_item.sold

Withdrawn

app/api/api/v1/stock_items.rb

  • POST api/stock_items/serialized/:id/withdraw
    • withdraw_at param
    • stock_item.withdraw!(withdraw_at)

app/controllers/products_controller.rb

  • #product_inventory
    • product.stock_items.where(withdrawn: true)
    • product.stock_items.where(hidden: true, sold: false, withdrawn: false)

app/controllers/stock_items_controller.rb

  • #update_params
    • :withdrawn, :withdrawn_at
    • tricky logic around withdrawn status

app/controllers/users_controller.rb

  • #withdrawn_stock_items

    • tabs...maybe ignore?
  • #withdrawn_stock_items

    • user.stock_items.withdrawn

app/entities/shoe_detail_entity.rb

  • #sizes_with_owned_count
    • not_withdrawn (part of larger query)

app/entities/stock_item_full_info_entity.rb

  • expose withdrawn

app/helpers/sqs_helper.rb

  • .update_variant_message
    • query where(withdrawn = true)

app/models/stock_item.rb

  • scope: :withdrawn

  • scope: :not_withdrawn

  • scope: :older_than

  • scope: :hidden

  • scope: :in_stock

  • scope: :not_withdrawn_pending

  • #mark_withdraw_pending!

    • update(withdraw_pending: true, withdraw_pending_at: )
  • `#withdraw!(withdrawn_at)

    • withdrawn = true
    • withdrawn_at
    • deducts quantity (SIDE EFFECT)
  • #status

  • #magento_sync_this

    • checks if !withdrawn
  • #editable?

    • !withdrawn

app/services/price_drop/change_request_handler.rb

  • #reject
    • stock_items.each(&:mark_withdraw_pending!)

app/services/price_drop/price_change_handler.rb

  • #stock_items
    • .not_withdraw_pending (part of larger query)

app/services/returns/stock_item_withdraw.rb

  • #withdraw

    • stock_item.update(withdraw_pending: false)
    • stock_item.withdraw!
  • #withdraw_pending_status

    • stock_item.withdraw_pending?

app/views/stock_items/show.html.erb

  • check_box :withdrawn

app/workers/magento_shipping_worker.rb

  • #perform
    • StockItem.not_withdrawn

Take Back

app/controllers/stock_items_controller.rb

  • #update_params
    • take_back

app/helpers/sqs_helper.rb

  • query for stock_items.where(take_back = true) & false

app/models/stock_item.rb

  • scope: :not_take_back

  • .add_stock!

    • StockItem.create!(take_back: params[:take_back]) <-- is this ever passed in?
  • mark_taken_back!

    • update!(take_back: true)
    • can probably remove it
  • #status

  • #magento_sync_this

app/services/price_drop/price_change_handler.rb

  • #stock_items
    • not_take_back (part of larger query)

app/views/stock_items/show.html.erb

  • check_box :take_back
  • hidden_field :take_back if !editable

Withdraw Pending

app/api/api/v1/returnables

  • GET api/v1/returnables

    • where(withdraw_pending: true)
  • PATCH api/v1/returnables

    • using service object (Returns::StockItemWithdraw)

app/helpers/sqs_helper.rb

  • .update_variant_message
    • query where(withdraw_pending = true)

Hidden

app/api/api/v1/stock_items.rb

  • POST api/stock_items/reserve
    • StockItem.hidden.where(
    • stock_item.hidden =
    • stock_item.hidden_reason

app/controllers/products_controller.rb

  • #product_inventory
    • product.stock_items.where(hidden: true, sold: false, withdrawn: false)

app/controllers/stock_items_controller.rb

  • #update_params

    • hidden
  • #create_params

    • hidden
  • #create

    • StockItem.from_submission!(hidden: create_params[:hidden])

app/controllers/users_controller.rb

  • helper_methods

    • hidden_stock_items
  • #hidden_stock_items

    • user.stock_items.hidden

app/entities/shoe_detail_entity.rb

  • #sizes_with_owned_count
    • StockItem.where().not_hidden (part of larger query)

app/entitites/stock_item_entity.rb

  • expose :hidden

app/entities/stock_item_full_info_entity.rb

  • expose :hidden

app/helpers/sqs_helper.rb

  • .update_variant_message
    • stock_items.where(hidden: true OR...)
    • stock_items.where(hidden: false AND ...)
    • delete message if stock_item.hidden_reason

app/models/stock_item.rb

  • scope: :hidden

  • scope: :in_stock

  • scope: :not_hidden

  • #.from_submission

    • hidden: params[:hidden]
  • .add_stock!

    • hidden: params[:hidden] || false
    • hidden_reason: params[:hidden] || false
  • #status

app/views/stock_items/index.html.erb

  • hidden_reason

app/views/stock_items/show.html.erb

  • hidden_field :hidden

app/views/users/show.html.erb

  • hidden_stock_items

Missing

app/controllers/stock_items_controller.rb

  • #update_params
    • missing

sqs_helper

  • #update_variant_message
    • stock_items.where(missing = true OR ...)
    • stock_items.where(missing = false AND ...)

app/models/stock_item.rb

  • .add_stock!

    • missing: params[:missing] || false
  • #status

app/views/stock_item/show.html.erb

  • check_box :missing
  • hidden_field :missing

On Sale

app/models/stock_item.rb

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