X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/155848c15844554a5d5fd50f9577aa2e19767d9e..8d26e6e46a5f2c15fa64b2cd4673bc5ee9ee100e:/app/models/collection.rb diff --git a/app/models/collection.rb b/app/models/collection.rb index 84464e1d02..6cbe330f3a 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,2 +1,31 @@ class Collection < ActiveRecord::Base + include AssignUuid + include KindAndEtag + include CommonApiTemplate + + api_accessible :superuser, :extend => :common do |t| + t.add :locator + t.add :portable_data_hash + t.add :name + t.add :redundancy + t.add :redundancy_confirmed_by_client + t.add :redundancy_confirmed_at + t.add :redundancy_confirmed_as + end + + def redundancy_status + if redundancy_confirmed_as.nil? + 'unconfirmed' + elsif redundancy_confirmed_as < redundancy + 'degraded' + else + if redundancy_confirmed_at.nil? + 'unconfirmed' + elsif Time.now - redundancy_confirmed_at < 7.days + 'OK' + else + 'stale' + end + end + end end