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
Jérome Perrin
gitlab-ce
Commits
7ad5a1b3
Commit
7ad5a1b3
authored
May 03, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add last_edited_at and last_edited_by attributes
parent
b82870af
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
8 deletions
+73
-8
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+7
-7
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
app/models/note.rb
app/models/note.rb
+1
-0
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+11
-0
app/services/notes/update_service.rb
app/services/notes/update_service.rb
+4
-0
db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb
...915_add_last_edited_at_and_last_edited_by_id_to_issues.rb
+14
-0
db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
...2512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
+14
-0
db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb
...last_edited_at_and_last_edited_by_id_to_merge_requests.rb
+14
-0
db/schema.rb
db/schema.rb
+7
-1
No files found.
app/helpers/application_helper.rb
View file @
7ad5a1b3
...
...
@@ -181,15 +181,15 @@ module ApplicationHelper
end
def
edited_time_ago_with_tooltip
(
object
,
placement:
'top'
,
html_class:
'time_ago'
,
include_author:
false
)
return
if
object
.
updated_at
==
object
.
created_at
return
if
object
.
last_edited_at
==
object
.
created_at
||
object
.
last_edited_at
.
blank?
content_tag
:small
,
class:
"edited-text"
do
output
=
content_tag
(
:span
,
"Edited "
)
output
<<
time_ago_with_tooltip
(
object
.
upda
ted_at
,
placement:
placement
,
html_class:
html_class
)
content_tag
:small
,
class:
'edited-text'
do
output
=
content_tag
(
:span
,
'Edited '
)
output
<<
time_ago_with_tooltip
(
object
.
last_edi
ted_at
,
placement:
placement
,
html_class:
html_class
)
if
include_author
&&
object
.
upda
ted_by
output
<<
content_tag
(
:span
,
" by "
)
output
<<
link_to_member
(
object
.
project
,
object
.
upda
ted_by
,
avatar:
false
,
author_class:
nil
)
if
include_author
&&
object
.
last_edi
ted_by
output
<<
content_tag
(
:span
,
' by '
)
output
<<
link_to_member
(
object
.
project
,
object
.
last_edi
ted_by
,
avatar:
false
,
author_class:
nil
)
end
output
...
...
app/models/concerns/issuable.rb
View file @
7ad5a1b3
...
...
@@ -28,6 +28,7 @@ module Issuable
belongs_to
:author
,
class_name:
"User"
belongs_to
:assignee
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
belongs_to
:last_edited_by
,
class_name:
'User'
belongs_to
:milestone
has_many
:notes
,
as: :noteable
,
inverse_of: :noteable
,
dependent: :destroy
do
def
authors_loaded?
...
...
app/models/note.rb
View file @
7ad5a1b3
...
...
@@ -38,6 +38,7 @@ class Note < ActiveRecord::Base
belongs_to
:noteable
,
polymorphic:
true
,
touch:
true
belongs_to
:author
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
belongs_to
:last_edited_by
,
class_name:
'User'
has_many
:todos
,
dependent: :destroy
has_many
:events
,
as: :target
,
dependent: :destroy
...
...
app/services/issuable_base_service.rb
View file @
7ad5a1b3
...
...
@@ -218,6 +218,13 @@ class IssuableBaseService < BaseService
if
issuable
.
changed?
||
params
.
present?
issuable
.
assign_attributes
(
params
.
merge
(
updated_by:
current_user
))
if
has_title_or_description_changed?
(
issuable
)
issuable
.
assign_attributes
(
params
.
merge
(
last_edited_at:
Time
.
now
,
last_edited_by:
current_user
))
end
before_update
(
issuable
)
if
issuable
.
with_transaction_returning_status
{
issuable
.
save
}
...
...
@@ -240,6 +247,10 @@ class IssuableBaseService < BaseService
old_label_ids
.
sort
!=
new_label_ids
.
sort
end
def
has_title_or_description_changed?
(
issuable
)
issuable
.
title_changed?
||
issuable
.
description_changed?
end
def
change_state
(
issuable
)
case
params
.
delete
(
:state_event
)
when
'reopen'
...
...
app/services/notes/update_service.rb
View file @
7ad5a1b3
...
...
@@ -5,7 +5,11 @@ module Notes
old_mentioned_users
=
note
.
mentioned_users
.
to_a
note
.
assign_attributes
(
params
)
params
.
merge!
(
last_edited_at:
Time
.
now
,
last_edited_by:
current_user
)
if
note
.
note_changed?
note
.
update_attributes
(
params
.
merge
(
updated_by:
current_user
))
note
.
create_new_cross_references!
(
current_user
)
if
note
.
previous_changes
.
include?
(
'note'
)
...
...
db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb
0 → 100644
View file @
7ad5a1b3
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddLastEditedAtAndLastEditedByIdToIssues
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
add_column
:issues
,
:last_edited_at
,
:timestamp
add_column
:issues
,
:last_edited_by_id
,
:integer
end
end
db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
0 → 100644
View file @
7ad5a1b3
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddLastEditedAtAndLastEditedByIdToNotes
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
add_column
:notes
,
:last_edited_at
,
:timestamp
add_column
:notes
,
:last_edited_by_id
,
:integer
end
end
db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb
0 → 100644
View file @
7ad5a1b3
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddLastEditedAtAndLastEditedByIdToMergeRequests
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
add_column
:merge_requests
,
:last_edited_at
,
:timestamp
add_column
:merge_requests
,
:last_edited_by_id
,
:integer
end
end
db/schema.rb
View file @
7ad5a1b3
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20170
426181740
)
do
ActiveRecord
::
Schema
.
define
(
version:
20170
503022548
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -488,6 +488,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do
t
.
integer
"relative_position"
t
.
datetime
"closed_at"
t
.
integer
"cached_markdown_version"
t
.
datetime
"last_edited_at"
t
.
integer
"last_edited_by_id"
end
add_index
"issues"
,
[
"assignee_id"
],
name:
"index_issues_on_assignee_id"
,
using: :btree
...
...
@@ -674,6 +676,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do
t
.
text
"description_html"
t
.
integer
"time_estimate"
t
.
integer
"cached_markdown_version"
t
.
datetime
"last_edited_at"
t
.
integer
"last_edited_by_id"
end
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
...
...
@@ -774,6 +778,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do
t
.
string
"discussion_id"
t
.
text
"note_html"
t
.
integer
"cached_markdown_version"
t
.
datetime
"last_edited_at"
t
.
integer
"last_edited_by_id"
end
add_index
"notes"
,
[
"author_id"
],
name:
"index_notes_on_author_id"
,
using: :btree
...
...
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