mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
fixed ruby style
This commit is contained in:
parent
8a6ff0c093
commit
4be597ba9d
@ -1,3 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Abuse is a report made by a visitor (not especially a logged user) who has signaled a content that seems abusive to his eyes.
|
||||
# It is currently used with projects.
|
||||
class Abuse < ActiveRecord::Base
|
||||
include NotifyWith::NotificationAttachedObject
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Export is a reference to a file asynchronously generated by the system and downloadable by the user
|
||||
class Export < ActiveRecord::Base
|
||||
require 'fileutils'
|
||||
|
||||
@ -13,25 +16,26 @@ class Export < ActiveRecord::Base
|
||||
dir = "exports/#{category}/#{export_type}"
|
||||
|
||||
# create directories if they doesn't exists (exports & type & id)
|
||||
FileUtils::mkdir_p dir
|
||||
"#{dir}/#{self.filename}"
|
||||
FileUtils.mkdir_p dir
|
||||
"#{dir}/#{filename}"
|
||||
end
|
||||
|
||||
def filename
|
||||
"#{export_type}-#{self.id}_#{self.created_at.strftime('%d%m%Y')}.xlsx"
|
||||
"#{export_type}-#{id}_#{created_at.strftime('%d%m%Y')}.xlsx"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_and_send_export
|
||||
case category
|
||||
when 'statistics'
|
||||
StatisticsExportWorker.perform_async(self.id)
|
||||
when 'users'
|
||||
UsersExportWorker.perform_async(self.id)
|
||||
when 'availabilities'
|
||||
AvailabilitiesExportWorker.perform_async(self.id)
|
||||
else
|
||||
raise NoMethodError, "Unknown export service for #{category}/#{export_type}"
|
||||
when 'statistics'
|
||||
StatisticsExportWorker.perform_async(id)
|
||||
when 'users'
|
||||
UsersExportWorker.perform_async(id)
|
||||
when 'availabilities'
|
||||
AvailabilitiesExportWorker.perform_async(id)
|
||||
else
|
||||
raise NoMethodError, "Unknown export service for #{category}/#{export_type}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user