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
934e9497
Commit
934e9497
authored
Apr 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop issues. Use add_concurrent_foreign_key.
parent
62480461
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
18 deletions
+15
-18
app/validators/cron_validator.rb
app/validators/cron_validator.rb
+0
-1
db/migrate/20170329095325_add_ref_to_triggers.rb
db/migrate/20170329095325_add_ref_to_triggers.rb
+0
-4
db/migrate/20170329095907_create_ci_trigger_schedules.rb
db/migrate/20170329095907_create_ci_trigger_schedules.rb
+9
-6
db/schema.rb
db/schema.rb
+1
-1
lib/ci/cron_parser.rb
lib/ci/cron_parser.rb
+5
-5
spec/models/ci/trigger_schedule_spec.rb
spec/models/ci/trigger_schedule_spec.rb
+0
-1
No files found.
app/validators/cron_validator.rb
View file @
934e9497
...
...
@@ -5,7 +5,6 @@ class CronValidator < ActiveModel::EachValidator
def
validate_each
(
record
,
attribute
,
value
)
cron_parser
=
Ci
::
CronParser
.
new
(
record
.
cron
,
record
.
cron_time_zone
)
is_valid_cron
,
is_valid_cron_time_zone
=
cron_parser
.
validation
next_time
=
cron_parser
.
next_time_from
(
Time
.
now
)
if
!
is_valid_cron
record
.
errors
.
add
(
:cron
,
" is invalid syntax"
)
...
...
db/migrate/20170329095325_add_ref_to_triggers.rb
View file @
934e9497
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddRefToTriggers
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
...
...
db/migrate/20170329095907_create_ci_trigger_schedules.rb
View file @
934e9497
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
CreateCiTriggerSchedules
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
disable_ddl_transaction!
def
up
create_table
:ci_trigger_schedules
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"trigger_id"
,
null:
false
...
...
@@ -21,6 +19,11 @@ class CreateCiTriggerSchedules < ActiveRecord::Migration
add_index
:ci_trigger_schedules
,
[
"next_run_at"
],
name:
"index_ci_trigger_schedules_on_next_run_at"
,
using: :btree
add_index
:ci_trigger_schedules
,
[
"project_id"
],
name:
"index_ci_trigger_schedules_on_project_id"
,
using: :btree
add_foreign_key
:ci_trigger_schedules
,
:ci_triggers
,
column: :trigger_id
,
on_delete: :cascade
add_concurrent_foreign_key
:ci_trigger_schedules
,
:ci_triggers
,
column: :trigger_id
,
on_delete: :cascade
end
def
down
remove_foreign_key
:ci_trigger_schedules
,
column: :trigger_id
drop_table
:ci_trigger_schedules
end
end
db/schema.rb
View file @
934e9497
...
...
@@ -1313,7 +1313,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do
add_foreign_key
"boards"
,
"projects"
add_foreign_key
"chat_teams"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"ci_trigger_schedules"
,
"ci_triggers"
,
column:
"trigger_id"
,
on_delete: :cascade
add_foreign_key
"ci_trigger_schedules"
,
"ci_triggers"
,
column:
"trigger_id"
,
name:
"fk_90a406cc94"
,
on_delete: :cascade
add_foreign_key
"ci_triggers"
,
"users"
,
column:
"owner_id"
,
name:
"fk_e8e10d1964"
,
on_delete: :cascade
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"label_priorities"
,
"labels"
,
on_delete: :cascade
...
...
lib/ci/cron_parser.rb
View file @
934e9497
module
Ci
class
CronParser
VALID_SYNTAX_SAMPLE_TIME_ZONE
=
'UTC'
VALID_SYNTAX_SAMPLE_CRON
=
'* * * * *'
VALID_SYNTAX_SAMPLE_TIME_ZONE
=
'UTC'
.
freeze
VALID_SYNTAX_SAMPLE_CRON
=
'* * * * *'
.
freeze
def
initialize
(
cron
,
cron_time_zone
=
'UTC'
)
@cron
=
cron
...
...
@@ -9,9 +9,9 @@ module Ci
end
def
next_time_from
(
time
)
cron
L
ine
=
try_parse_cron
(
@cron
,
@cron_time_zone
)
if
cron
L
ine
.
present?
cron
L
ine
.
next_time
(
time
).
in_time_zone
(
Time
.
zone
)
cron
_l
ine
=
try_parse_cron
(
@cron
,
@cron_time_zone
)
if
cron
_l
ine
.
present?
cron
_l
ine
.
next_time
(
time
).
in_time_zone
(
Time
.
zone
)
else
nil
end
...
...
spec/models/ci/trigger_schedule_spec.rb
View file @
934e9497
require
'spec_helper'
describe
Ci
::
TriggerSchedule
,
models:
true
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:trigger
)
}
it
{
is_expected
.
to
respond_to
:ref
}
...
...
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