Commit 81e78711 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-03-08

# Conflicts:
#	config/routes/user.rb
#	db/schema.rb

[ci skip]
parents dfb021cc ac1f3bc3
......@@ -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
......@@ -197,6 +197,10 @@ class MergeRequestDiff < ActiveRecord::Base
CompareService.new(project, head_commit_sha).execute(project, sha, straight: true)
end
def commits_count
super || merge_request_diff_commits.size
end
private
def create_merge_request_diff_files(diffs)
......
......@@ -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
......
---
title: Improve database response time for user activity listing.
merge_request: 17454
author:
type: performance
---
title: Ensure foreign keys on clusters applications
merge_request: 17488
author:
type: other
---
title: Adding missing indexes on taggings table
merge_request:
author:
type: performance
---
title: Add index on section_name_id on ci_build_trace_sections table
merge_request:
author:
type: performance
<<<<<<< HEAD
## EE-specific
get 'unsubscribes/:email', to: 'unsubscribes#show', as: :unsubscribe
post 'unsubscribes/:email', to: 'unsubscribes#create'
## EE-specific
=======
>>>>>>> upstream/master
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
registrations: :registrations,
passwords: :passwords,
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
existing = Clusters::Cluster
.joins(:application_ingress)
.where('clusters.id = clusters_applications_ingress.cluster_id')
Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch|
batch.delete_all
end
unless foreign_keys_for(:clusters_applications_ingress, :cluster_id).any?
add_concurrent_foreign_key :clusters_applications_ingress, :clusters,
column: :cluster_id,
on_delete: :cascade
end
existing = Clusters::Cluster
.joins(:application_prometheus)
.where('clusters.id = clusters_applications_prometheus.cluster_id')
Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch|
batch.delete_all
end
unless foreign_keys_for(:clusters_applications_prometheus, :cluster_id).any?
add_concurrent_foreign_key :clusters_applications_prometheus, :clusters,
column: :cluster_id,
on_delete: :cascade
end
end
def down
if foreign_keys_for(:clusters_applications_ingress, :cluster_id).any?
remove_foreign_key :clusters_applications_ingress, column: :cluster_id
end
if foreign_keys_for(:clusters_applications_prometheus, :cluster_id).any?
remove_foreign_key :clusters_applications_prometheus, column: :cluster_id
end
end
end
class CleanCommitsCountMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
Gitlab::BackgroundMigration.steal('AddMergeRequestDiffCommitsCount')
end
def down
end
end
# This migration comes from acts_as_taggable_on_engine (originally 6)
#
# It has been modified to handle no-downtime GitLab migrations. Several
# indexes have been removed since they are not needed for GitLab.
class AddMissingIndexesActsAsTaggableOnEngine < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
add_concurrent_index :taggings, [:taggable_id, :taggable_type] unless index_exists? :taggings, [:taggable_id, :taggable_type]
end
def down
remove_concurrent_index :taggings, :tag_id
remove_concurrent_index :taggings, [:taggable_id, :taggable_type]
end
end
class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
# MySQL may already have this as a foreign key
unless index_exists?(:ci_build_trace_sections, :section_name_id)
add_concurrent_index :ci_build_trace_sections, :section_name_id
end
end
def down
# We cannot remove index for MySQL because it's needed for foreign key
if Gitlab::Database.postgresql?
remove_concurrent_index :ci_build_trace_sections, :section_name_id
end
end
end
......@@ -11,7 +11,11 @@
#
# It's strongly recommended that you check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(version: 20180307164427) do
=======
ActiveRecord::Schema.define(version: 20180308052825) do
>>>>>>> upstream/master
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -340,6 +344,7 @@ ActiveRecord::Schema.define(version: 20180307164427) do
add_index "ci_build_trace_sections", ["build_id", "section_name_id"], name: "index_ci_build_trace_sections_on_build_id_and_section_name_id", unique: true, using: :btree
add_index "ci_build_trace_sections", ["project_id"], name: "index_ci_build_trace_sections_on_project_id", using: :btree
add_index "ci_build_trace_sections", ["section_name_id"], name: "index_ci_build_trace_sections_on_section_name_id", using: :btree
create_table "ci_builds", force: :cascade do |t|
t.string "status"
......@@ -2293,7 +2298,9 @@ ActiveRecord::Schema.define(version: 20180307164427) do
end
add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
add_index "taggings", ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_taggable_type", using: :btree
create_table "tags", force: :cascade do |t|
t.string "name"
......@@ -2613,7 +2620,12 @@ ActiveRecord::Schema.define(version: 20180307164427) do
add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade
add_foreign_key "clusters", "users", on_delete: :nullify
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
<<<<<<< HEAD
add_foreign_key "clusters_applications_ingress", "clusters", on_delete: :cascade
=======
add_foreign_key "clusters_applications_ingress", "clusters", name: "fk_753a7b41c1", on_delete: :cascade
add_foreign_key "clusters_applications_prometheus", "clusters", name: "fk_557e773639", on_delete: :cascade
>>>>>>> upstream/master
add_foreign_key "clusters_applications_runners", "ci_runners", column: "runner_id", name: "fk_02de2ded36", on_delete: :nullify
add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade
add_foreign_key "container_repositories", "projects"
......
......@@ -299,9 +299,9 @@ sudo usermod -aG redis git
### Clone the Source
# Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 10-5-stable gitlab
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 10-6-stable gitlab
**Note:** You can change `10-5-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server!
**Note:** You can change `10-6-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server!
### Configure It
......
This diff is collapsed.
......@@ -31,8 +31,7 @@ with all their related data and be moved into a new GitLab instance.
| GitLab version | Import/Export version |
| ---------------- | --------------------- |
| 10.6 to current | 0.2.3 |
| 10.4 | 0.2.2 |
| 10.4 to current | 0.2.2 |
| 10.3 | 0.2.1 |
| 10.0 | 0.2.0 |
| 9.4.0 | 0.1.8 |
......
......@@ -1437,16 +1437,6 @@ module Gitlab
output
end
def can_be_merged?(source_sha, target_branch)
gitaly_migrate(:can_be_merged) do |is_enabled|
if is_enabled
gitaly_can_be_merged?(source_sha, find_branch(target_branch).target)
else
rugged_can_be_merged?(source_sha, target_branch)
end
end
end
def last_commit_for_path(sha, path)
gitaly_migrate(:last_commit_for_path) do |is_enabled|
if is_enabled
......@@ -2408,14 +2398,6 @@ module Gitlab
.map { |c| commit(c) }
end
def gitaly_can_be_merged?(their_commit, our_commit)
!gitaly_conflicts_client(our_commit, their_commit).conflicts?
end
def rugged_can_be_merged?(their_commit, our_commit)
!rugged.merge_commits(our_commit, their_commit).conflicts?
end
def last_commit_for_path_by_gitaly(sha, path)
gitaly_commit_client.last_commit_for_path(sha, path)
end
......
......@@ -3,7 +3,7 @@ module Gitlab
extend self
# For every version update, the version history in import_export.md has to be kept up to date.
VERSION = '0.2.3'.freeze
VERSION = '0.2.2'.freeze
FILENAME_LIMIT = 50
def export_path(relative_path:)
......
......@@ -31,7 +31,6 @@ describe User do
it { is_expected.to have_many(:keys).dependent(:destroy) }
it { is_expected.to have_many(:deploy_keys).dependent(:destroy) }
it { is_expected.to have_many(:events).dependent(:destroy) }
it { is_expected.to have_many(:recent_events).class_name('Event') }
it { is_expected.to have_many(:issues).dependent(:destroy) }
it { is_expected.to have_many(:notes).dependent(:destroy) }
it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
......
# See https://www.dartlang.org/tools/private-files.html
# See https://www.dartlang.org/guides/libraries/private-files
# Files and directories created by pub
.dart_tool/
......
# C++ objects and libs
*.slo
*.lo
*.o
......@@ -11,7 +10,6 @@
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
......@@ -35,13 +33,11 @@ Makefile*
target_wrapper.*
# QtCreator
*.autosave
# QtCtreator Qml
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCtreator CMake
# QtCreator CMake
CMakeLists.txt.user*
......@@ -31,3 +31,6 @@ vignettes/*.pdf
# Temporary files created by R markdown
*.utf8.md
*.knit.md
# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
rsconnect/
......@@ -110,6 +110,14 @@ acs-*.bib
*.gaux
*.gtex
# htlatex
*.4ct
*.4tc
*.idv
*.lg
*.trc
*.xref
# hyperref
*.brf
......
......@@ -259,9 +259,6 @@ FakesAssemblies/
.ntvs_analysis.dat
node_modules/
# TypeScript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
......
......@@ -36,7 +36,6 @@ variables:
KUBERNETES_VERSION: 1.8.6
HELM_VERSION: 2.6.1
CODECLIMATE_VERSION: 0.69.0
stages:
- build
......@@ -286,6 +285,8 @@ production:
export CI_APPLICATION_TAG=$CI_COMMIT_SHA
export CI_CONTAINER_NAME=ci_job_build_${CI_JOB_ID}
export TILLER_NAMESPACE=$KUBE_NAMESPACE
# Extract "MAJOR.MINOR" from CI_SERVER_VERSION and generate "MAJOR-MINOR-stable" for Static Code Analysis
export SCA_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
function sast_container() {
if [[ -n "$CI_REGISTRY_USER" ]]; then
......@@ -306,20 +307,16 @@ production:
}
function codeclimate() {
cc_opts="--env CODECLIMATE_CODE="$PWD" \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc"
docker run ${cc_opts} "codeclimate/codeclimate:${CODECLIMATE_VERSION}" init
docker run ${cc_opts} "codeclimate/codeclimate:${CODECLIMATE_VERSION}" analyze -f json > codeclimate.json
docker run --env CODECLIMATE_CODE="$PWD" \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc \
"registry.gitlab.com/gitlab-org/security-products/codequality/codeclimate:${SCA_VERSION}" analyze -f json > codeclimate.json
}
function sast() {
case "$CI_SERVER_VERSION" in
*-ee)
# Extract "MAJOR.MINOR" from CI_SERVER_VERSION and generate "MAJOR-MINOR-stable"
SAST_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
# Deprecation notice for CONFIDENCE_LEVEL variable
if [ -z "$SAST_CONFIDENCE_LEVEL" -a "$CONFIDENCE_LEVEL" ]; then
......@@ -331,7 +328,7 @@ production:
--env SAST_DISABLE_REMOTE_CHECKS="${SAST_DISABLE_REMOTE_CHECKS:-false}" \
--volume "$PWD:/code" \
--volume /var/run/docker.sock:/var/run/docker.sock \
"registry.gitlab.com/gitlab-org/security-products/sast:$SAST_VERSION" /app/bin/run /code
"registry.gitlab.com/gitlab-org/security-products/sast:$SCA_VERSION" /app/bin/run /code
;;
*)
echo "GitLab EE is required"
......
This diff is collapsed.
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