unepwcmc/SAPI

View on GitHub
app/models/trade/trade_data_download.rb

Summary

Maintainability
A
0 mins
Test Coverage
# == Schema Information
#
# Table name: trade_trade_data_downloads
#
#  id             :integer          not null, primary key
#  user_ip        :string(255)
#  report_type    :string(255)
#  year_from      :integer
#  year_to        :integer
#  taxon          :string(255)
#  appendix       :string(255)
#  importer       :text
#  exporter       :text
#  origin         :text
#  term           :text
#  unit           :text
#  source         :text
#  purpose        :text
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#  number_of_rows :integer
#  city           :string
#  country        :string
#  organization   :string
#

class Trade::TradeDataDownload < ApplicationRecord
  # Used by app/models/trade/trade_data_download_logger.rb
  # attr_accessible :user_ip, :report_type, :year_from, :year_to, :taxon,
  #  :appendix, :importer, :exporter, :origin, :term, :unit, :source, :purpose,
  #  :number_of_rows, :city, :country, :organization

  after_commit :async_downloads_cache_cleanup, on: [:create, :update]

  private

  def async_downloads_cache_cleanup
    DownloadsCacheCleanupWorker.perform_async('trade_download_stats')
  end
end