Class: Repository

Inherits:
ApplicationRecord show all
Includes:
Housekeeping::Timestamps, Housekeeping::Users, Shared::IsApplicationData, Shared::IsData, Shared::Notes, Shared::SharedAcrossProjects
Defined in:
app/models/repository.rb

Overview

A Repository is a physical location that stores collection objects.

In TaxonWorks, repositories are presently built exclusively at grbio.org/.

Instance Attribute Summary (collapse)

Attributes included from Housekeeping::Users

#by

Class Method Summary (collapse)

Methods included from Housekeeping::Timestamps

#data_breakdown_for_chartkick_recent

Methods included from Housekeeping::Users

#set_created_by_id, #set_updated_by_id

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (String) acronym

Returns a short form name for the repository

Returns:

  • (String)

    a short form name for the repository



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

- (String) institutional_LSID

Returns sensu grbio.org/

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

- (Boolean) is_index_herbariorum

Returns see grbio.org/

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

- (String) name

Returns the name of the repository

Returns:

  • (String)

    the name of the repository



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

- (String) status

Returns see grbio.org/

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

- (String) url

Returns see grbio.org/

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/repository.rb', line 29

class Repository < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::Notes
  include Shared::SharedAcrossProjects
  include Shared::IsData
  include Shared::IsApplicationData

  has_many :collection_objects, inverse_of: :repository, dependent: :restrict_with_error
  validates_presence_of :name, :url, :acronym, :status

  scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
  scope :used_in_project, -> (project_id) { joins(:collection_objects).where( collection_objects: { project_id: project_id } ) }

  def self.select_optimized(user_id, project_id)
    h = {
      recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
      pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
    }

    h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
    h
  end

end

Class Method Details

+ (Object) select_optimized(user_id, project_id)



43
44
45
46
47
48
49
50
51
# File 'app/models/repository.rb', line 43

def self.select_optimized(user_id, project_id)
  h = {
    recent: Repository.used_in_project(project_id).used_recently.limit(10).distinct.to_a,
    pinboard: Repository.pinned_by(user_id).pinned_in_project(project_id).to_a
  }

  h[:quick] = (Repository.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a  + h[:recent][0..3]).uniq
  h
end