Class: Repository

Inherits:
ApplicationRecord show all
Includes:
Housekeeping::Timestamps, Housekeeping::Users, Shared::AlternateValues, Shared::Confidences, Shared::DataAttributes, Shared::Identifiers, Shared::IsApplicationData, Shared::IsData, Shared::Notes, Shared::SharedAcrossProjects, Shared::Tags
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/.

Defined Under Namespace

Classes: Autocomplete

Constant Summary collapse

ALTERNATE_VALUES_FOR =
[:name, :acronym]

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

Instance Attribute Details

#acronymString

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

#institutional_LSIDString

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

#is_index_herbariorumBoolean

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

#nameString

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

#statusString

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

#urlString

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
54
55
56
57
58
59
60
61
62
# 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
  include Shared::AlternateValues
  include Shared::DataAttributes
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::Confidences

  ALTERNATE_VALUES_FOR = [:name, :acronym]

  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).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
               Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
    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

.select_optimized(user_id, project_id) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'app/models/repository.rb', line 51

def self.select_optimized(user_id, project_id)
  h = {
    recent: (Repository.used_in_project(project_id).where(collection_objects: {created_by_id: user_id}).used_recently.limit(10).distinct.to_a +
             Repository.where(created_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
  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