Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cc6f35d7
Commit
cc6f35d7
authored
Apr 14, 2021
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project overrides query
parent
07566d4f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
5 deletions
+35
-5
app/models/concerns/integration.rb
app/models/concerns/integration.rb
+2
-2
changelogs/unreleased/218252-update-project-overrides-query.yml
...logs/unreleased/218252-update-project-overrides-query.yml
+5
-0
db/migrate/20210414095944_add_index_services_on_project_and_type_where_inherit_null.rb
..._index_services_on_project_and_type_where_inherit_null.rb
+17
-0
db/schema_migrations/20210414095944
db/schema_migrations/20210414095944
+1
-0
db/structure.sql
db/structure.sql
+2
-0
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+8
-3
No files found.
app/models/concerns/integration.rb
View file @
cc6f35d7
...
@@ -6,12 +6,12 @@ module Integration
...
@@ -6,12 +6,12 @@ module Integration
class_methods
do
class_methods
do
def
with_custom_integration_for
(
integration
,
page
=
nil
,
per
=
nil
)
def
with_custom_integration_for
(
integration
,
page
=
nil
,
per
=
nil
)
custom_integration_project_ids
=
Service
custom_integration_project_ids
=
Service
.
select
(
:project_id
)
.
where
(
type:
integration
.
type
)
.
where
(
type:
integration
.
type
)
.
where
(
inherit_from_id:
nil
)
.
where
(
inherit_from_id:
nil
)
.
distinct
# Required until https://gitlab.com/gitlab-org/gitlab/-/issues/207385
.
where
.
not
(
project_id:
nil
)
.
page
(
page
)
.
page
(
page
)
.
per
(
per
)
.
per
(
per
)
.
pluck
(
:project_id
)
Project
.
where
(
id:
custom_integration_project_ids
)
Project
.
where
(
id:
custom_integration_project_ids
)
end
end
...
...
changelogs/unreleased/218252-update-project-overrides-query.yml
0 → 100644
View file @
cc6f35d7
---
title
:
Add index services on project and type where inherit is
null
merge_request
:
59168
author
:
type
:
other
db/migrate/20210414095944_add_index_services_on_project_and_type_where_inherit_null.rb
0 → 100644
View file @
cc6f35d7
# frozen_string_literal: true
class
AddIndexServicesOnProjectAndTypeWhereInheritNull
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
INDEX_NAME
=
'index_services_on_project_and_type_where_inherit_null'
def
up
add_concurrent_index
(
:services
,
[
:project_id
,
:type
],
where:
'inherit_from_id IS NULL'
,
name:
INDEX_NAME
)
end
def
down
remove_concurrent_index_by_name
(
:services
,
INDEX_NAME
)
end
end
db/schema_migrations/20210414095944
0 → 100644
View file @
cc6f35d7
843d9eabf8b67fe10d9eb453e887032d5b88b8594ae666bc6c6ac81e20e1ab53
\ No newline at end of file
db/structure.sql
View file @
cc6f35d7
...
@@ -23864,6 +23864,8 @@ CREATE INDEX index_service_desk_enabled_projects_on_id_creator_id_created_at ON
...
@@ -23864,6 +23864,8 @@ CREATE INDEX index_service_desk_enabled_projects_on_id_creator_id_created_at ON
CREATE INDEX index_services_on_inherit_from_id ON services USING btree (inherit_from_id);
CREATE INDEX index_services_on_inherit_from_id ON services USING btree (inherit_from_id);
CREATE INDEX index_services_on_project_and_type_where_inherit_null ON services USING btree (project_id, type) WHERE (inherit_from_id IS NULL);
CREATE UNIQUE INDEX index_services_on_project_id_and_type_unique ON services USING btree (project_id, type);
CREATE UNIQUE INDEX index_services_on_project_id_and_type_unique ON services USING btree (project_id, type);
CREATE INDEX index_services_on_template ON services USING btree (template);
CREATE INDEX index_services_on_template ON services USING btree (template);
spec/models/integration_spec.rb
View file @
cc6f35d7
...
@@ -6,23 +6,28 @@ RSpec.describe Integration do
...
@@ -6,23 +6,28 @@ RSpec.describe Integration do
let_it_be
(
:project_1
)
{
create
(
:project
)
}
let_it_be
(
:project_1
)
{
create
(
:project
)
}
let_it_be
(
:project_2
)
{
create
(
:project
)
}
let_it_be
(
:project_2
)
{
create
(
:project
)
}
let_it_be
(
:project_3
)
{
create
(
:project
)
}
let_it_be
(
:project_3
)
{
create
(
:project
)
}
let_it_be
(
:project_4
)
{
create
(
:project
)
}
let_it_be
(
:instance_integration
)
{
create
(
:jira_service
,
:instance
)
}
let_it_be
(
:instance_integration
)
{
create
(
:jira_service
,
:instance
)
}
before
do
before
do
create
(
:jira_service
,
project:
project_1
,
inherit_from_id:
instance_integration
.
id
)
create
(
:jira_service
,
project:
project_1
,
inherit_from_id:
instance_integration
.
id
)
create
(
:jira_service
,
project:
project_2
,
inherit_from_id:
nil
)
create
(
:jira_service
,
project:
project_2
,
inherit_from_id:
nil
)
create
(
:slack_service
,
project:
project_3
,
inherit_from_id:
nil
)
create
(
:jira_service
,
group:
create
(
:group
),
project:
nil
,
inherit_from_id:
nil
)
create
(
:jira_service
,
project:
project_3
,
inherit_from_id:
nil
)
create
(
:slack_service
,
project:
project_4
,
inherit_from_id:
nil
)
end
end
describe
'.with_custom_integration_for'
do
describe
'.with_custom_integration_for'
do
it
'returns projects with custom integrations'
do
it
'returns projects with custom integrations'
do
expect
(
Project
.
with_custom_integration_for
(
instance_integration
)).
to
contain_exactly
(
project_2
)
# We use pagination to verify that the group is excluded from the query
expect
(
Project
.
with_custom_integration_for
(
instance_integration
,
0
,
2
)).
to
contain_exactly
(
project_2
,
project_3
)
expect
(
Project
.
with_custom_integration_for
(
instance_integration
)).
to
contain_exactly
(
project_2
,
project_3
)
end
end
end
end
describe
'.without_integration'
do
describe
'.without_integration'
do
it
'returns projects without integration'
do
it
'returns projects without integration'
do
expect
(
Project
.
without_integration
(
instance_integration
)).
to
contain_exactly
(
project_
3
)
expect
(
Project
.
without_integration
(
instance_integration
)).
to
contain_exactly
(
project_
4
)
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment