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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
d5c91bb9
Commit
d5c91bb9
authored
Dec 09, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate CI WebHooks and Emails to new tables
parent
2988e1fb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
6 deletions
+55
-6
app/models/project_services/builds_email_service.rb
app/models/project_services/builds_email_service.rb
+7
-4
app/workers/build_email_worker.rb
app/workers/build_email_worker.rb
+1
-1
db/migrate/20151209144329_migrate_ci_web_hooks.rb
db/migrate/20151209144329_migrate_ci_web_hooks.rb
+12
-0
db/migrate/20151209145909_migrate_ci_emails.rb
db/migrate/20151209145909_migrate_ci_emails.rb
+16
-0
db/schema.rb
db/schema.rb
+1
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+18
-0
No files found.
app/models/project_services/builds_email_service.rb
View file @
d5c91bb9
...
...
@@ -54,7 +54,7 @@ class BuildsEmailService < Service
def
fields
[
{
type:
'textarea'
,
name:
'recipients'
,
placeholder:
'Emails separated by
whitespace
'
},
{
type:
'textarea'
,
name:
'recipients'
,
placeholder:
'Emails separated by
comma
'
},
{
type:
'checkbox'
,
name:
'add_pusher'
,
label:
'Add pusher to recipients list'
},
{
type:
'checkbox'
,
name:
'notify_only_broken_builds'
},
]
...
...
@@ -72,10 +72,13 @@ class BuildsEmailService < Service
end
def
all_recipients
(
data
)
all_recipients
=
[]
all_recipients
<<=
recipients
.
split
(
','
)
if
add_pusher?
&&
data
[
:user
][
:email
]
recipients
+
"
#{
data
[
:user
][
:email
]
}
"
else
recipients
all_recipients
<<
"
#{
data
[
:user
][
:email
]
}
"
end
all_recipients
end
end
app/workers/build_email_worker.rb
View file @
d5c91bb9
...
...
@@ -2,7 +2,7 @@ class BuildEmailWorker
include
Sidekiq
::
Worker
def
perform
(
build_id
,
recipients
,
push_data
)
recipients
.
split
(
' '
).
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
begin
case
push_data
[
'build_status'
]
when
'success'
...
...
db/migrate/20151209144329_migrate_ci_web_hooks.rb
0 → 100644
View file @
d5c91bb9
class
MigrateCiWebHooks
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
execute
(
'INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, build_events) '
\
"SELECT ci_web_hooks.url, projects.id, 'ProjectHook', ci_web_hooks.created_at, ci_web_hooks.updated_at,
#{
false_value
}
,
#{
true_value
}
FROM ci_web_hooks "
\
'JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id '
\
'JOIN projects ON ci_projects.gitlab_id = projects.id'
)
end
end
db/migrate/20151209145909_migrate_ci_emails.rb
0 → 100644
View file @
d5c91bb9
class
MigrateCiEmails
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
execute
(
'INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) '
\
"SELECT projects.id, 'BuildsEmailService', ci_services.created_at, ci_services.updated_at,
#{
true_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
false_value
}
,
#{
true_value
}
, "
\
"CONCAT('{
\"
notify_only_broken_builds
\"
:
\"
', ci_projects.email_only_broken_builds, "
\
"'
\"
,
\"
add_pusher
\"
:
\"
', ci_projects.email_add_pusher, '
\"
,
\"
recipients
\"
:
\"
', ci_projects.email_recipients, '
\"
}') "
\
'FROM ci_services '
\
'JOIN ci_projects ON ci_services.project_id = ci_projects.id '
\
'JOIN projects ON ci_projects.gitlab_id = projects.id '
\
"WHERE ci_services.type = 'Ci::MailService' AND ci_services.active"
)
end
end
db/schema.rb
View file @
d5c91bb9
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015120
3162134
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015120
9145909
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
lib/gitlab/database.rb
View file @
d5c91bb9
...
...
@@ -7,5 +7,23 @@ module Gitlab
def
self
.
postgresql?
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
==
'postgresql'
end
def
true_value
case
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
when
'postgresql'
"'t'"
else
1
end
end
def
false_value
case
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
when
'postgresql'
"'f'"
else
0
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