diff --git a/app/models/client.rb b/app/models/client.rb index 44febc2..c1d896d 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -1,12 +1,31 @@ class Client < ActiveRecord::Base self.table_name = :Client self.primary_key = :ClientId alias_attribute :name, :Name alias_attribute :uname, :Uname alias_attribute :auto_prune, :AutoPrune alias_attribute :file_retention, :FileRetention alias_attribute :job_retention, :JobRetention has_many :jobs, foreign_key: :ClientId + + DAY_SECS = 60 * 60 * 24 + + # Helper method. It shows the client's job retention, + # (which is expressed in seconds) in days. + # + # @return [Integer] + def job_retention_days + job_retention / DAY_SECS + end + + + # Helper method. It shows the client's file retention, + # (which is expressed in seconds) in days. + # + # @return [Integer] + def file_retention_days + file_retention / DAY_SECS + end end diff --git a/app/views/clients/_client.html.erb b/app/views/clients/_client.html.erb index 6b4f6cd..b5e9fda 100644 --- a/app/views/clients/_client.html.erb +++ b/app/views/clients/_client.html.erb @@ -1,7 +1,7 @@ <%= link_to client.name, client %> <%= client.uname %> <%= client.auto_prune %> - <%= client.file_retention %> - <%= client.job_retention %> + <%= client.file_retention_days %> + <%= client.job_retention_days %> diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb index 5730c5e..b804a7d 100644 --- a/app/views/clients/index.html.erb +++ b/app/views/clients/index.html.erb @@ -1,19 +1,19 @@

My Hosts

- - + + <%= render partial: 'client', collection: @clients %>
Name Uname AutoPruneFileRetentionJobRetentionFileRetention (days)JobRetention (days)