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
c34a1332
Commit
c34a1332
authored
Mar 21, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove out-of-context changes
parent
a3bb9546
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
21 deletions
+64
-21
app/controllers/projects/jobs_controller.rb
app/controllers/projects/jobs_controller.rb
+11
-11
app/finders/user_recent_events_finder.rb
app/finders/user_recent_events_finder.rb
+38
-7
app/models/project.rb
app/models/project.rb
+2
-1
app/models/user.rb
app/models/user.rb
+3
-1
changelogs/unreleased/40525-listing-user-activity-timeouts.yml
...elogs/unreleased/40525-listing-user-activity-timeouts.yml
+5
-0
changelogs/unreleased/43802-ensure-foreign-keys-on-clusters-applications.yml
...ed/43802-ensure-foreign-keys-on-clusters-applications.yml
+5
-0
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+0
-1
No files found.
app/controllers/projects/jobs_controller.rb
View file @
c34a1332
...
...
@@ -4,9 +4,9 @@ class Projects::JobsController < Projects::ApplicationController
before_action
:build
,
except:
[
:index
,
:cancel_all
]
before_action
:authorize_read_build!
,
only:
[
:index
,
:show
,
:status
,
:raw
,
:trace
]
only:
[
:index
,
:show
,
:status
,
:raw
,
:trace
]
before_action
:authorize_update_build!
,
except:
[
:index
,
:show
,
:status
,
:raw
,
:trace
,
:cancel_all
,
:erase
]
except:
[
:index
,
:show
,
:status
,
:raw
,
:trace
,
:cancel_all
,
:erase
]
before_action
:authorize_erase_build!
,
only:
[
:erase
]
layout
'project'
...
...
@@ -27,10 +27,10 @@ class Projects::JobsController < Projects::ApplicationController
@builds
end
@builds
=
@builds
.
includes
([
{
pipeline: :project
},
:project
,
:tags
])
{
pipeline: :project
},
:project
,
:tags
])
@builds
=
@builds
.
page
(
params
[
:page
]).
per
(
30
).
without_count
end
...
...
@@ -55,8 +55,8 @@ class Projects::JobsController < Projects::ApplicationController
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
render
json:
BuildSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent
(
@build
,
{},
BuildDetailsEntity
)
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent
(
@build
,
{},
BuildDetailsEntity
)
end
end
end
...
...
@@ -105,14 +105,14 @@ class Projects::JobsController < Projects::ApplicationController
def
status
render
json:
BuildSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent_status
(
@build
)
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent_status
(
@build
)
end
def
erase
if
@build
.
erase
(
erased_by:
current_user
)
redirect_to
project_job_path
(
project
,
@build
),
notice:
"Job has been successfully erased!"
notice:
"Job has been successfully erased!"
else
respond_422
end
...
...
app/finders/user_recent_events_finder.rb
View file @
c34a1332
...
...
@@ -12,6 +12,8 @@ class UserRecentEventsFinder
attr_reader
:current_user
,
:target_user
,
:params
LIMIT
=
20
def
initialize
(
current_user
,
target_user
,
params
=
{})
@current_user
=
current_user
@target_user
=
target_user
...
...
@@ -19,15 +21,44 @@ class UserRecentEventsFinder
end
def
execute
target_user
.
recent_events
.
merge
(
projects_for_current_user
)
.
references
(
:project
)
recent_events
(
params
[
:offset
]
||
0
)
.
joins
(
:project
)
.
with_associations
.
limit_recent
(
20
,
params
[
:offset
])
.
limit_recent
(
LIMIT
,
params
[
:offset
])
end
private
def
recent_events
(
offset
)
sql
=
<<~
SQL
(
#{
projects
}
) AS projects_for_join
JOIN (
#{
target_events
.
to_sql
}
) AS
#{
Event
.
table_name
}
ON
#{
Event
.
table_name
}
.project_id = projects_for_join.id
SQL
# Workaround for https://github.com/rails/rails/issues/24193
Event
.
from
([
Arel
.
sql
(
sql
)])
end
def
projects_for_current_user
ProjectsFinder
.
new
(
current_user:
current_user
).
execute
def
target_events
Event
.
where
(
author:
target_user
)
end
def
projects
# Compile a list of projects `current_user` interacted with
# and `target_user` is allowed to see.
authorized
=
target_user
.
project_interactions
.
joins
(
:project_authorizations
)
.
where
(
project_authorizations:
{
user:
current_user
})
.
select
(
:id
)
visible
=
target_user
.
project_interactions
.
where
(
visibility_level:
[
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
PUBLIC
])
.
select
(
:id
)
Gitlab
::
SQL
::
Union
.
new
([
authorized
,
visible
]).
to_sql
end
end
app/models/project.rb
View file @
c34a1332
...
...
@@ -193,6 +193,8 @@ class Project < ActiveRecord::Base
has_many
:todos
has_many
:notification_settings
,
as: :source
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:internal_ids
has_one
:import_data
,
class_name:
'ProjectImportData'
,
inverse_of: :project
,
autosave:
true
has_one
:project_feature
,
inverse_of: :project
has_one
:statistics
,
class_name:
'ProjectStatistics'
...
...
@@ -297,7 +299,6 @@ class Project < ActiveRecord::Base
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
...
...
app/models/user.rb
View file @
c34a1332
...
...
@@ -116,13 +116,15 @@ class User < ActiveRecord::Base
has_many
:project_authorizations
has_many
:authorized_projects
,
through: :project_authorizations
,
source: :project
has_many
:user_interacted_projects
has_many
:project_interactions
,
through: :user_interacted_projects
,
source: :project
,
class_name:
'Project'
has_many
:snippets
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:notes
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:issues
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:merge_requests
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:subscriptions
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:recent_events
,
->
{
order
"id DESC"
},
foreign_key: :author_id
,
class_name:
"Event"
has_many
:oauth_applications
,
class_name:
'Doorkeeper::Application'
,
as: :owner
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:abuse_report
,
dependent: :destroy
,
foreign_key: :user_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:reported_abuse_reports
,
dependent: :destroy
,
foreign_key: :reporter_id
,
class_name:
"AbuseReport"
# rubocop:disable Cop/ActiveRecordDependent
...
...
changelogs/unreleased/40525-listing-user-activity-timeouts.yml
0 → 100644
View file @
c34a1332
---
title
:
Improve database response time for user activity listing.
merge_request
:
17454
author
:
type
:
performance
changelogs/unreleased/43802-ensure-foreign-keys-on-clusters-applications.yml
0 → 100644
View file @
c34a1332
---
title
:
Ensure foreign keys on clusters applications
merge_request
:
17488
author
:
type
:
other
config/sidekiq_queues.yml
View file @
c34a1332
...
...
@@ -64,7 +64,6 @@
- [update_user_activity, 1]
- [propagate_service_template, 1]
- [background_migration, 1]
- [object_storage_upload, 1]
- [gcp_cluster, 1]
- [project_migrate_hashed_storage, 1]
- [storage_migrator, 1]
...
...
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