Commit fea9400e authored by Robert Speicher's avatar Robert Speicher

Merge branch 'add-pluck-primary-key' into 'master'

Add a thin encapsulation around .pluck(:id)

See merge request gitlab-org/gitlab-ce!26669
parents 36ecc88d f086dbf6
# frozen_string_literal: true
class AbuseReport < ActiveRecord::Base
class AbuseReport < ApplicationRecord
include CacheMarkdownField
cache_markdown_field :message, pipeline: :single_line
......
# frozen_string_literal: true
class Appearance < ActiveRecord::Base
class Appearance < ApplicationRecord
include CacheableAttributes
include CacheMarkdownField
include ObjectStorage::BackgroundMove
......
......@@ -7,6 +7,14 @@ class ApplicationRecord < ActiveRecord::Base
where(id: ids)
end
def self.id_not_in(ids)
where.not(id: ids)
end
def self.pluck_primary_key
where(nil).pluck(self.primary_key)
end
def self.safe_find_or_create_by!(*args)
safe_find_or_create_by(*args).tap do |record|
record.validate! unless record.persisted?
......
# frozen_string_literal: true
class ApplicationSetting < ActiveRecord::Base
class ApplicationSetting < ApplicationRecord
include CacheableAttributes
include CacheMarkdownField
include TokenAuthenticatable
......
# frozen_string_literal: true
class ApplicationSetting
class Term < ActiveRecord::Base
class Term < ApplicationRecord
include CacheMarkdownField
has_many :term_agreements
......
# frozen_string_literal: true
class AuditEvent < ActiveRecord::Base
class AuditEvent < ApplicationRecord
serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize
belongs_to :user, foreign_key: :author_id
......
# frozen_string_literal: true
class AwardEmoji < ActiveRecord::Base
class AwardEmoji < ApplicationRecord
DOWNVOTE_NAME = "thumbsdown".freeze
UPVOTE_NAME = "thumbsup".freeze
......
# frozen_string_literal: true
class Badge < ActiveRecord::Base
class Badge < ApplicationRecord
include FromUnion
# This structure sets the placeholders that the urls
......
# frozen_string_literal: true
class Board < ActiveRecord::Base
class Board < ApplicationRecord
belongs_to :group
belongs_to :project
......
# frozen_string_literal: true
# Tracks which boards in a specific group a user has visited
class BoardGroupRecentVisit < ActiveRecord::Base
class BoardGroupRecentVisit < ApplicationRecord
belongs_to :user
belongs_to :group
belongs_to :board
......
# frozen_string_literal: true
# Tracks which boards in a specific project a user has visited
class BoardProjectRecentVisit < ActiveRecord::Base
class BoardProjectRecentVisit < ApplicationRecord
belongs_to :user
belongs_to :project
belongs_to :board
......
# frozen_string_literal: true
class BroadcastMessage < ActiveRecord::Base
class BroadcastMessage < ApplicationRecord
include CacheMarkdownField
include Sortable
......
# frozen_string_literal: true
class ChatName < ActiveRecord::Base
class ChatName < ApplicationRecord
LAST_USED_AT_INTERVAL = 1.hour
belongs_to :service
......
# frozen_string_literal: true
class ChatTeam < ActiveRecord::Base
class ChatTeam < ApplicationRecord
validates :team_id, presence: true
validates :namespace, uniqueness: true
......
......@@ -3,7 +3,7 @@
module Ci
# The purpose of this class is to store Build related data that can be disposed.
# Data that should be persisted forever, should be stored with Ci::Build model.
class BuildMetadata < ActiveRecord::Base
class BuildMetadata < ApplicationRecord
extend Gitlab::Ci::Model
include Presentable
include ChronicDurationAttribute
......
......@@ -3,7 +3,7 @@
module Ci
# The purpose of this class is to store Build related runner session.
# Data will be removed after transitioning from running to any state.
class BuildRunnerSession < ActiveRecord::Base
class BuildRunnerSession < ApplicationRecord
extend Gitlab::Ci::Model
self.table_name = 'ci_builds_runner_session'
......
# frozen_string_literal: true
module Ci
class BuildTraceChunk < ActiveRecord::Base
class BuildTraceChunk < ApplicationRecord
include FastDestroyAll
include ::Gitlab::ExclusiveLeaseHelpers
extend Gitlab::Ci::Model
......
# frozen_string_literal: true
module Ci
class BuildTraceSection < ActiveRecord::Base
class BuildTraceSection < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :build, class_name: 'Ci::Build'
......
# frozen_string_literal: true
module Ci
class BuildTraceSectionName < ActiveRecord::Base
class BuildTraceSectionName < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :project
......
# frozen_string_literal: true
module Ci
class GroupVariable < ActiveRecord::Base
class GroupVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Presentable
......
# frozen_string_literal: true
module Ci
class JobArtifact < ActiveRecord::Base
class JobArtifact < ApplicationRecord
include AfterCommitQueue
include ObjectStorage::BackgroundMove
extend Gitlab::Ci::Model
......
# frozen_string_literal: true
module Ci
class Pipeline < ActiveRecord::Base
class Pipeline < ApplicationRecord
extend Gitlab::Ci::Model
include HasStatus
include Importable
......@@ -184,7 +184,7 @@ module Ci
scope :sort_by_merge_request_pipelines, -> do
sql = 'CASE ci_pipelines.source WHEN (?) THEN 0 ELSE 1 END, ci_pipelines.id DESC'
query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, sources[:merge_request_event]]) # rubocop:disable GitlabSecurity/PublicSend
query = ApplicationRecord.send(:sanitize_sql_array, [sql, sources[:merge_request_event]]) # rubocop:disable GitlabSecurity/PublicSend
order(query)
end
......
# frozen_string_literal: true
module Ci
class PipelineChatData < ActiveRecord::Base
class PipelineChatData < ApplicationRecord
self.table_name = 'ci_pipeline_chat_data'
belongs_to :chat_name
......
# frozen_string_literal: true
module Ci
class PipelineSchedule < ActiveRecord::Base
class PipelineSchedule < ApplicationRecord
extend Gitlab::Ci::Model
include Importable
include IgnorableColumn
......
# frozen_string_literal: true
module Ci
class PipelineScheduleVariable < ActiveRecord::Base
class PipelineScheduleVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
......
# frozen_string_literal: true
module Ci
class PipelineVariable < ActiveRecord::Base
class PipelineVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
......
# frozen_string_literal: true
module Ci
class Runner < ActiveRecord::Base
class Runner < ApplicationRecord
extend Gitlab::Ci::Model
include Gitlab::SQL::Pattern
include IgnorableColumn
......
# frozen_string_literal: true
module Ci
class RunnerNamespace < ActiveRecord::Base
class RunnerNamespace < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :runner, inverse_of: :runner_namespaces, validate: true
......
# frozen_string_literal: true
module Ci
class RunnerProject < ActiveRecord::Base
class RunnerProject < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :runner, inverse_of: :runner_projects
......
# frozen_string_literal: true
module Ci
class Stage < ActiveRecord::Base
class Stage < ApplicationRecord
extend Gitlab::Ci::Model
include Importable
include HasStatus
......
# frozen_string_literal: true
module Ci
class Trigger < ActiveRecord::Base
class Trigger < ApplicationRecord
extend Gitlab::Ci::Model
include IgnorableColumn
include Presentable
......
# frozen_string_literal: true
module Ci
class TriggerRequest < ActiveRecord::Base
class TriggerRequest < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :trigger
......
# frozen_string_literal: true
module Ci
class Variable < ActiveRecord::Base
class Variable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Presentable
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class CertManager < ActiveRecord::Base
class CertManager < ApplicationRecord
VERSION = 'v0.5.2'.freeze
self.table_name = 'clusters_applications_cert_managers'
......
......@@ -4,7 +4,7 @@ require 'openssl'
module Clusters
module Applications
class Helm < ActiveRecord::Base
class Helm < ApplicationRecord
self.table_name = 'clusters_applications_helm'
attr_encrypted :ca_key,
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class Ingress < ActiveRecord::Base
class Ingress < ApplicationRecord
VERSION = '1.1.2'.freeze
self.table_name = 'clusters_applications_ingress'
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class Jupyter < ActiveRecord::Base
class Jupyter < ApplicationRecord
VERSION = '0.9-174bbd5'.freeze
self.table_name = 'clusters_applications_jupyter'
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class Knative < ActiveRecord::Base
class Knative < ApplicationRecord
VERSION = '0.3.0'.freeze
REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze
METRICS_CONFIG = 'https://storage.googleapis.com/triggermesh-charts/istio-metrics.yaml'.freeze
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class Prometheus < ActiveRecord::Base
class Prometheus < ApplicationRecord
include PrometheusAdapter
VERSION = '6.7.3'
......
......@@ -2,7 +2,7 @@
module Clusters
module Applications
class Runner < ActiveRecord::Base
class Runner < ApplicationRecord
VERSION = '0.3.0'.freeze
self.table_name = 'clusters_applications_runners'
......
# frozen_string_literal: true
module Clusters
class Cluster < ActiveRecord::Base
class Cluster < ApplicationRecord
include Presentable
include Gitlab::Utils::StrongMemoize
include FromUnion
......
# frozen_string_literal: true
module Clusters
class Group < ActiveRecord::Base
class Group < ApplicationRecord
self.table_name = 'cluster_groups'
belongs_to :cluster, class_name: 'Clusters::Cluster'
......
# frozen_string_literal: true
module Clusters
class KubernetesNamespace < ActiveRecord::Base
class KubernetesNamespace < ApplicationRecord
include Gitlab::Kubernetes
self.table_name = 'clusters_kubernetes_namespaces'
......
......@@ -2,7 +2,7 @@
module Clusters
module Platforms
class Kubernetes < ActiveRecord::Base
class Kubernetes < ApplicationRecord
include Gitlab::Kubernetes
include ReactiveCaching
include EnumWithNil
......
# frozen_string_literal: true
module Clusters
class Project < ActiveRecord::Base
class Project < ApplicationRecord
self.table_name = 'cluster_projects'
belongs_to :cluster, class_name: 'Clusters::Cluster'
......
......@@ -2,7 +2,7 @@
module Clusters
module Providers
class Gcp < ActiveRecord::Base
class Gcp < ApplicationRecord
self.table_name = 'cluster_providers_gcp'
belongs_to :cluster, inverse_of: :provider_gcp, class_name: 'Clusters::Cluster'
......
# frozen_string_literal: true
class CommitStatus < ActiveRecord::Base
class CommitStatus < ApplicationRecord
include HasStatus
include Importable
include AfterCommitQueue
......
......@@ -7,7 +7,7 @@
#
# For example, let's generate internal ids for Issue per Project:
# ```
# class Issue < ActiveRecord::Base
# class Issue < ApplicationRecord
# has_internal_id :iid, scope: :project, init: ->(s) { s.project.issues.maximum(:iid) }
# end
# ```
......
......@@ -5,7 +5,7 @@
#
# Example:
#
# class User < ActiveRecord::Base
# class User < ApplicationRecord
# include IgnorableColumn
#
# ignore_column :updated_at
......
......@@ -7,7 +7,7 @@
#
# Usage:
#
# class Issue < ActiveRecord::Base
# class Issue < ApplicationRecord
# include Participable
#
# # ...
......
......@@ -7,7 +7,7 @@
#
# Example of use:
#
# class Foo < ActiveRecord::Base
# class Foo < ApplicationRecord
# include ReactiveCaching
#
# self.reactive_cache_key = ->(thing) { ["foo", thing.id] }
......
......@@ -39,7 +39,7 @@ module ShaAttribute
end
def database_exists?
ActiveRecord::Base.connection
ApplicationRecord.connection
true
rescue
......
......@@ -6,7 +6,7 @@
#
# Usage:
#
# class Milestone < ActiveRecord::Base
# class Milestone < ApplicationRecord
# strip_attributes :title
# end
#
......
# frozen_string_literal: true
class ContainerRepository < ActiveRecord::Base
class ContainerRepository < ApplicationRecord
include Gitlab::Utils::StrongMemoize
belongs_to :project
......
# frozen_string_literal: true
module ConversationalDevelopmentIndex
class Metric < ActiveRecord::Base
class Metric < ApplicationRecord
include Presentable
self.table_name = 'conversational_development_index_metrics'
......
# frozen_string_literal: true
class DeployKeysProject < ActiveRecord::Base
class DeployKeysProject < ApplicationRecord
belongs_to :project
belongs_to :deploy_key, inverse_of: :deploy_keys_projects
......
# frozen_string_literal: true
class DeployToken < ActiveRecord::Base
class DeployToken < ApplicationRecord
include Expirable
include TokenAuthenticatable
include PolicyActor
......
# frozen_string_literal: true
class Deployment < ActiveRecord::Base
class Deployment < ApplicationRecord
include AtomicInternalId
include IidRoutes
include AfterCommitQueue
......
# frozen_string_literal: true
class Email < ActiveRecord::Base
class Email < ApplicationRecord
include Sortable
include Gitlab::SQL::Pattern
......
# frozen_string_literal: true
class Environment < ActiveRecord::Base
class Environment < ApplicationRecord
include Gitlab::Utils::StrongMemoize
# Used to generate random suffixes for the slug
LETTERS = 'a'..'z'
......
......@@ -2,7 +2,7 @@
# Placeholder class for model that is implemented in EE
# It reserves '&' as a reference prefix, but the table does not exists in CE
class Epic < ActiveRecord::Base
class Epic < ApplicationRecord
def self.link_reference_pattern
nil
end
......
# frozen_string_literal: true
module ErrorTracking
class ProjectErrorTrackingSetting < ActiveRecord::Base
class ProjectErrorTrackingSetting < ApplicationRecord
include Gitlab::Utils::StrongMemoize
include ReactiveCaching
......
# frozen_string_literal: true
class Event < ActiveRecord::Base
class Event < ApplicationRecord
include Sortable
include IgnorableColumn
include FromUnion
......
# frozen_string_literal: true
class ForkNetwork < ActiveRecord::Base
class ForkNetwork < ApplicationRecord
belongs_to :root_project, class_name: 'Project'
has_many :fork_network_members
has_many :projects, through: :fork_network_members
......
# frozen_string_literal: true
class ForkNetworkMember < ActiveRecord::Base
class ForkNetworkMember < ApplicationRecord
belongs_to :fork_network
belongs_to :project
belongs_to :forked_from_project, class_name: 'Project'
......
# frozen_string_literal: true
class GpgKey < ActiveRecord::Base
class GpgKey < ApplicationRecord
KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze
KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze
......
# frozen_string_literal: true
class GpgKeySubkey < ActiveRecord::Base
class GpgKeySubkey < ApplicationRecord
include ShaAttribute
sha_attribute :keyid
......
# frozen_string_literal: true
class GroupCustomAttribute < ActiveRecord::Base
class GroupCustomAttribute < ApplicationRecord
belongs_to :group
validates :group, :key, :value, presence: true
......
# frozen_string_literal: true
class WebHook < ActiveRecord::Base
class WebHook < ApplicationRecord
include Sortable
attr_encrypted :token,
......
# frozen_string_literal: true
class WebHookLog < ActiveRecord::Base
class WebHookLog < ApplicationRecord
belongs_to :web_hook
serialize :request_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize
......
# frozen_string_literal: true
class Identity < ActiveRecord::Base
class Identity < ApplicationRecord
include Sortable
include CaseSensitivity
......
# frozen_string_literal: true
class Identity < ActiveRecord::Base
class Identity < ApplicationRecord
# This module and method are defined in a separate file to allow EE to
# redefine the `scopes` method before it is used in the `Identity` model.
module UniquenessScopes
......
# frozen_string_literal: true
class ImportExportUpload < ActiveRecord::Base
class ImportExportUpload < ApplicationRecord
include WithUploads
include ObjectStorage::BackgroundMove
......
......@@ -15,7 +15,7 @@
# In order to leverage InternalId for other usages, the idea is to
# * Add `usage` value to enum
# * (Optionally) add columns to `internal_ids` if needed for scope.
class InternalId < ActiveRecord::Base
class InternalId < ApplicationRecord
belongs_to :project
belongs_to :namespace
......
......@@ -2,7 +2,7 @@
require 'carrierwave/orm/activerecord'
class Issue < ActiveRecord::Base
class Issue < ApplicationRecord
include AtomicInternalId
include IidRoutes
include Issuable
......
# frozen_string_literal: true
class Issue::Metrics < ActiveRecord::Base
class Issue::Metrics < ApplicationRecord
belongs_to :issue
def record!
......
# frozen_string_literal: true
class IssueAssignee < ActiveRecord::Base
class IssueAssignee < ApplicationRecord
belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id
end
......@@ -2,7 +2,7 @@
require 'digest/md5'
class Key < ActiveRecord::Base
class Key < ApplicationRecord
include AfterCommitQueue
include Sortable
......
# frozen_string_literal: true
class Label < ActiveRecord::Base
class Label < ApplicationRecord
include CacheMarkdownField
include Referable
include Subscribable
......
# frozen_string_literal: true
class LabelLink < ActiveRecord::Base
class LabelLink < ApplicationRecord
include Importable
belongs_to :target, polymorphic: true, inverse_of: :label_links # rubocop:disable Cop/PolymorphicAssociations
......
# frozen_string_literal: true
class LabelPriority < ActiveRecord::Base
class LabelPriority < ApplicationRecord
belongs_to :project
belongs_to :label
......
# frozen_string_literal: true
class LfsFileLock < ActiveRecord::Base
class LfsFileLock < ApplicationRecord
belongs_to :project
belongs_to :user
......
# frozen_string_literal: true
class LfsObject < ActiveRecord::Base
class LfsObject < ApplicationRecord
include AfterCommitQueue
include ObjectStorage::BackgroundMove
......
# frozen_string_literal: true
class LfsObjectsProject < ActiveRecord::Base
class LfsObjectsProject < ApplicationRecord
belongs_to :project
belongs_to :lfs_object
......
# frozen_string_literal: true
class List < ActiveRecord::Base
class List < ApplicationRecord
belongs_to :board
belongs_to :label
......
# frozen_string_literal: true
class Member < ActiveRecord::Base
class Member < ApplicationRecord
include AfterCommitQueue
include Sortable
include Importable
......
# frozen_string_literal: true
class MergeRequest < ActiveRecord::Base
class MergeRequest < ApplicationRecord
include AtomicInternalId
include IidRoutes
include Issuable
......
# frozen_string_literal: true
class MergeRequest::Metrics < ActiveRecord::Base
class MergeRequest::Metrics < ApplicationRecord
belongs_to :merge_request
belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :pipeline_id
belongs_to :latest_closed_by, class_name: 'User'
......
# frozen_string_literal: true
class MergeRequestDiff < ActiveRecord::Base
class MergeRequestDiff < ApplicationRecord
include Sortable
include Importable
include ManualInverseAssociation
......
# frozen_string_literal: true
class MergeRequestDiffCommit < ActiveRecord::Base
class MergeRequestDiffCommit < ApplicationRecord
include ShaAttribute
belongs_to :merge_request_diff
......
# frozen_string_literal: true
class MergeRequestDiffFile < ActiveRecord::Base
class MergeRequestDiffFile < ApplicationRecord
include Gitlab::EncodingHelper
include DiffFile
......
# frozen_string_literal: true
class MergeRequestsClosingIssues < ActiveRecord::Base
class MergeRequestsClosingIssues < ApplicationRecord
belongs_to :merge_request
belongs_to :issue
......
# frozen_string_literal: true
class Milestone < ActiveRecord::Base
class Milestone < ApplicationRecord
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
MilestoneStruct = Struct.new(:title, :name, :id)
......
......@@ -3,7 +3,7 @@
# A note on the root of an issue, merge request, commit, or snippet.
#
# A note of this type is never resolvable.
class Note < ActiveRecord::Base
class Note < ApplicationRecord
extend ActiveModel::Naming
include Participable
include Mentionable
......
# frozen_string_literal: true
class NoteDiffFile < ActiveRecord::Base
class NoteDiffFile < ApplicationRecord
include DiffFile
scope :for_commit_or_unresolved, -> do
......
# frozen_string_literal: true
class NotificationSetting < ActiveRecord::Base
class NotificationSetting < ApplicationRecord
include IgnorableColumn
ignore_column :events
......
# frozen_string_literal: true
class PagesDomain < ActiveRecord::Base
class PagesDomain < ApplicationRecord
VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
VERIFICATION_THRESHOLD = 3.days.freeze
......
# frozen_string_literal: true
class PersonalAccessToken < ActiveRecord::Base
class PersonalAccessToken < ApplicationRecord
include Expirable
include IgnorableColumn
include TokenAuthenticatable
......
......@@ -3,7 +3,7 @@
# The PoolRepository model is the database equivalent of an ObjectPool for Gitaly
# That is; PoolRepository is the record in the database, ObjectPool is the
# repository on disk
class PoolRepository < ActiveRecord::Base
class PoolRepository < ApplicationRecord
include Shardable
include AfterCommitQueue
......
# frozen_string_literal: true
module Postgresql
class ReplicationSlot < ActiveRecord::Base
class ReplicationSlot < ApplicationRecord
self.table_name = 'pg_replication_slots'
# Returns true if there are any replication slots in use.
......
# frozen_string_literal: true
class ProgrammingLanguage < ActiveRecord::Base
class ProgrammingLanguage < ApplicationRecord
validates :name, presence: true
validates :color, allow_blank: false, color: true
......
......@@ -2,7 +2,7 @@
require 'carrierwave/orm/activerecord'
class Project < ActiveRecord::Base
class Project < ApplicationRecord
include Gitlab::ConfigHelper
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
......
# frozen_string_literal: true
class ProjectAuthorization < ActiveRecord::Base
class ProjectAuthorization < ApplicationRecord
include FromUnion
belongs_to :user
......
# frozen_string_literal: true
class ProjectAutoDevops < ActiveRecord::Base
class ProjectAutoDevops < ApplicationRecord
belongs_to :project
enum deploy_strategy: {
......
# frozen_string_literal: true
class ProjectCiCdSetting < ActiveRecord::Base
class ProjectCiCdSetting < ApplicationRecord
belongs_to :project, inverse_of: :ci_cd_settings
# The version of the schema that first introduced this model/table.
......
# frozen_string_literal: true
class ProjectCustomAttribute < ActiveRecord::Base
class ProjectCustomAttribute < ApplicationRecord
belongs_to :project
validates :project, :key, :value, presence: true
......
# frozen_string_literal: true
class ProjectDailyStatistic < ActiveRecord::Base
class ProjectDailyStatistic < ApplicationRecord
belongs_to :project
scope :of_project, -> (project) { where(project: project) }
......
# frozen_string_literal: true
class ProjectDeployToken < ActiveRecord::Base
class ProjectDeployToken < ApplicationRecord
belongs_to :project
belongs_to :deploy_token, inverse_of: :project_deploy_tokens
......
# frozen_string_literal: true
class ProjectFeature < ActiveRecord::Base
class ProjectFeature < ApplicationRecord
# == Project features permissions
#
# Grants access level to project tools
......
# frozen_string_literal: true
class ProjectGroupLink < ActiveRecord::Base
class ProjectGroupLink < ApplicationRecord
include Expirable
GUEST = 10
......
......@@ -2,7 +2,7 @@
require 'carrierwave/orm/activerecord'
class ProjectImportData < ActiveRecord::Base
class ProjectImportData < ApplicationRecord
belongs_to :project, inverse_of: :import_data
attr_encrypted :credentials,
key: Settings.attr_encrypted_db_key_base,
......
# frozen_string_literal: true
class ProjectImportState < ActiveRecord::Base
class ProjectImportState < ApplicationRecord
include AfterCommitQueue
self.table_name = "project_mirror_data"
......
# frozen_string_literal: true
class ProjectRepository < ActiveRecord::Base
class ProjectRepository < ApplicationRecord
include Shardable
belongs_to :project, inverse_of: :project_repository
......
# frozen_string_literal: true
class ProjectStatistics < ActiveRecord::Base
class ProjectStatistics < ApplicationRecord
belongs_to :project
belongs_to :namespace
......
# frozen_string_literal: true
class PrometheusMetric < ActiveRecord::Base
class PrometheusMetric < ApplicationRecord
belongs_to :project, validate: true, inverse_of: :prometheus_metrics
enum group: {
......
# frozen_string_literal: true
class ProtectedBranch < ActiveRecord::Base
class ProtectedBranch < ApplicationRecord
include ProtectedRef
protected_ref_access_levels :merge, :push
......
# frozen_string_literal: true
class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base
class ProtectedBranch::MergeAccessLevel < ApplicationRecord
include ProtectedBranchAccess
end
# frozen_string_literal: true
class ProtectedBranch::PushAccessLevel < ActiveRecord::Base
class ProtectedBranch::PushAccessLevel < ApplicationRecord
include ProtectedBranchAccess
end
# frozen_string_literal: true
class ProtectedTag < ActiveRecord::Base
class ProtectedTag < ApplicationRecord
include ProtectedRef
validates :name, uniqueness: { scope: :project_id }
......
# frozen_string_literal: true
class ProtectedTag::CreateAccessLevel < ActiveRecord::Base
class ProtectedTag::CreateAccessLevel < ApplicationRecord
include ProtectedTagAccess
def check_access(user)
......
# frozen_string_literal: true
class PushEventPayload < ActiveRecord::Base
class PushEventPayload < ApplicationRecord
include ShaAttribute
belongs_to :event, inverse_of: :push_event_payload
......
# frozen_string_literal: true
class RedirectRoute < ActiveRecord::Base
class RedirectRoute < ApplicationRecord
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
validates :source, presence: true
......
# frozen_string_literal: true
class Release < ActiveRecord::Base
class Release < ApplicationRecord
include CacheMarkdownField
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module Releases
class Link < ActiveRecord::Base
class Link < ApplicationRecord
self.table_name = 'release_links'
belongs_to :release
......
# frozen_string_literal: true
class RemoteMirror < ActiveRecord::Base
class RemoteMirror < ApplicationRecord
include AfterCommitQueue
include MirrorAuthentication
......
# frozen_string_literal: true
class RepositoryLanguage < ActiveRecord::Base
class RepositoryLanguage < ApplicationRecord
belongs_to :project
belongs_to :programming_language
......
......@@ -2,7 +2,7 @@
# This model is not used yet, it will be used for:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48483
class ResourceLabelEvent < ActiveRecord::Base
class ResourceLabelEvent < ApplicationRecord
include Importable
include Gitlab::Utils::StrongMemoize
include CacheMarkdownField
......
# frozen_string_literal: true
class Route < ActiveRecord::Base
class Route < ApplicationRecord
include CaseSensitivity
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
......
# frozen_string_literal: true
class SentNotification < ActiveRecord::Base
class SentNotification < ApplicationRecord
serialize :position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
belongs_to :project
......
......@@ -2,7 +2,7 @@
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
class Service < ApplicationRecord
include Sortable
include Importable
include ProjectServicesLoggable
......
# frozen_string_literal: true
class Shard < ActiveRecord::Base
class Shard < ApplicationRecord
# Store shard names from the configuration file in the database. This is not a
# list of active shards - we just want to assign an immutable, unique ID to
# every shard name for easy indexing / referencing.
......
# frozen_string_literal: true
class Snippet < ActiveRecord::Base
class Snippet < ApplicationRecord
include Gitlab::VisibilityLevel
include Redactable
include CacheMarkdownField
......
# frozen_string_literal: true
class SpamLog < ActiveRecord::Base
class SpamLog < ApplicationRecord
belongs_to :user
validates :user, presence: true
......
# frozen_string_literal: true
class Subscription < ActiveRecord::Base
class Subscription < ApplicationRecord
belongs_to :user
belongs_to :project
belongs_to :subscribable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
......
# frozen_string_literal: true
class SystemNoteMetadata < ActiveRecord::Base
class SystemNoteMetadata < ApplicationRecord
# These notes's action text might contain a reference that is external.
# We should always force a deep validation upon references that are found
# in this note type.
......
# frozen_string_literal: true
class TermAgreement < ActiveRecord::Base
class TermAgreement < ApplicationRecord
belongs_to :term, class_name: 'ApplicationSetting::Term'
belongs_to :user
......
# frozen_string_literal: true
class Timelog < ActiveRecord::Base
class Timelog < ApplicationRecord
validates :time_spent, :user, presence: true
validate :issuable_id_is_present
......
# frozen_string_literal: true
class Todo < ActiveRecord::Base
class Todo < ApplicationRecord
include Sortable
include FromUnion
......
# frozen_string_literal: true
class TrendingProject < ActiveRecord::Base
class TrendingProject < ApplicationRecord
belongs_to :project
# The number of months to include in the trending calculation.
......
......@@ -2,7 +2,7 @@
# Registration information for U2F (universal 2nd factor) devices, like Yubikeys
class U2fRegistration < ActiveRecord::Base
class U2fRegistration < ApplicationRecord
belongs_to :user
def self.register(user, app_id, params, challenges)
......
# frozen_string_literal: true
class Upload < ActiveRecord::Base
class Upload < ApplicationRecord
# Upper limit for foreground checksum processing
CHECKSUM_THRESHOLD = 100.megabytes
......
......@@ -432,7 +432,7 @@ class User < ApplicationRecord
fuzzy_arel_match(:name, query, lower_exact_match: true)
.or(fuzzy_arel_match(:username, query, lower_exact_match: true))
.or(arel_table[:email].eq(query))
).reorder(order % { query: ActiveRecord::Base.connection.quote(query) }, :name)
).reorder(order % { query: ApplicationRecord.connection.quote(query) }, :name)
end
# Limits the result set to users _not_ in the given query/list of IDs.
......
# frozen_string_literal: true
class UserAgentDetail < ActiveRecord::Base
class UserAgentDetail < ApplicationRecord
belongs_to :subject, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
validates :user_agent, :ip_address, :subject_id, :subject_type, presence: true
......
# frozen_string_literal: true
class UserCallout < ActiveRecord::Base
class UserCallout < ApplicationRecord
belongs_to :user
# We use `UserCalloutEnums.feature_names` here so that EE can more easily
......
# frozen_string_literal: true
class UserCustomAttribute < ActiveRecord::Base
class UserCustomAttribute < ApplicationRecord
belongs_to :user
validates :user_id, :key, :value, presence: true
......
# frozen_string_literal: true
class UserInteractedProject < ActiveRecord::Base
class UserInteractedProject < ApplicationRecord
belongs_to :user
belongs_to :project
......
# frozen_string_literal: true
class UserPreference < ActiveRecord::Base
class UserPreference < ApplicationRecord
# We could use enums, but Rails 4 doesn't support multiple
# enum options with same name for multiple fields, also it creates
# extra methods that aren't really needed here.
......
# frozen_string_literal: true
class UserStatus < ActiveRecord::Base
class UserStatus < ApplicationRecord
include CacheMarkdownField
self.primary_key = :user_id
......
# frozen_string_literal: true
class UserSyncedAttributesMetadata < ActiveRecord::Base
class UserSyncedAttributesMetadata < ApplicationRecord
belongs_to :user
validates :user, presence: true
......
# frozen_string_literal: true
class UsersStarProject < ActiveRecord::Base
class UsersStarProject < ApplicationRecord
belongs_to :project, counter_cache: :star_count, touch: true
belongs_to :user
......
......@@ -76,13 +76,11 @@ class IssuableBaseService < BaseService
find_or_create_label_ids
end
# rubocop: disable CodeReuse/ActiveRecord
def filter_labels_in_param(key)
return if params[key].to_a.empty?
params[key] = available_labels.where(id: params[key]).pluck(:id)
params[key] = available_labels.id_in(params[key]).pluck_primary_key
end
# rubocop: enable CodeReuse/ActiveRecord
def find_or_create_label_ids
labels = params.delete(:labels)
......
......@@ -8,15 +8,13 @@ module MergeRequests
@merge_request = merge_request
end
# rubocop: disable CodeReuse/ActiveRecord
def execute
diffs = @merge_request.non_latest_diffs.with_files
diffs.each_batch(of: BATCH_SIZE) do |relation, index|
ids = relation.pluck(:id).map { |id| [id] }
ids = relation.pluck_primary_key.map { |id| [id] }
DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -26,17 +26,15 @@ module Milestones
private
# rubocop: disable CodeReuse/ActiveRecord
def milestone_ids_for_merge(group_milestone)
# Pluck need to be used here instead of select so the array of ids
# is persistent after old milestones gets deleted.
@milestone_ids_for_merge ||= begin
search_params = { title: group_milestone.title, project_ids: group_project_ids, state: 'all' }
milestones = MilestonesFinder.new(search_params).execute
milestones.pluck(:id)
milestones.pluck_primary_key
end
end
# rubocop: enable CodeReuse/ActiveRecord
def move_children_to_group_milestone(group_milestone)
milestone_ids_for_merge(group_milestone).in_groups_of(100, false) do |milestone_ids|
......
......@@ -554,7 +554,7 @@ module QuickActions
current_user.can?(:"update_#{issuable.to_ability_name}", issuable) &&
issuable.project.boards.count == 1
end
# rubocop: disable CodeReuse/ActiveRecord
command :board_move do |target_list_name|
label_ids = find_label_ids(target_list_name)
......@@ -562,14 +562,17 @@ module QuickActions
label_id = label_ids.first
# Ensure this label corresponds to a list on the board
next unless Label.on_project_boards(issuable.project_id).where(id: label_id).exists?
next unless Label.on_project_boards(issuable.project_id).id_in(label_id).exists?
@updates[:remove_label_ids] = issuable
.labels
.on_project_boards(issuable.project_id)
.id_not_in(label_id)
.pluck_primary_key
@updates[:remove_label_ids] =
issuable.labels.on_project_boards(issuable.project_id).where.not(id: label_id).pluck(:id)
@updates[:add_label_ids] = [label_id]
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Mark this issue as a duplicate of another issue'
explanation do |duplicate_reference|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment