mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +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
|
class Abuse < ActiveRecord::Base
|
||||||
include NotifyWith::NotificationAttachedObject
|
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
|
class Export < ActiveRecord::Base
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
@ -13,25 +16,26 @@ class Export < ActiveRecord::Base
|
|||||||
dir = "exports/#{category}/#{export_type}"
|
dir = "exports/#{category}/#{export_type}"
|
||||||
|
|
||||||
# create directories if they doesn't exists (exports & type & id)
|
# create directories if they doesn't exists (exports & type & id)
|
||||||
FileUtils::mkdir_p dir
|
FileUtils.mkdir_p dir
|
||||||
"#{dir}/#{self.filename}"
|
"#{dir}/#{filename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_and_send_export
|
def generate_and_send_export
|
||||||
case category
|
case category
|
||||||
when 'statistics'
|
when 'statistics'
|
||||||
StatisticsExportWorker.perform_async(self.id)
|
StatisticsExportWorker.perform_async(id)
|
||||||
when 'users'
|
when 'users'
|
||||||
UsersExportWorker.perform_async(self.id)
|
UsersExportWorker.perform_async(id)
|
||||||
when 'availabilities'
|
when 'availabilities'
|
||||||
AvailabilitiesExportWorker.perform_async(self.id)
|
AvailabilitiesExportWorker.perform_async(id)
|
||||||
else
|
else
|
||||||
raise NoMethodError, "Unknown export service for #{category}/#{export_type}"
|
raise NoMethodError, "Unknown export service for #{category}/#{export_type}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user