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
c158cba6
Commit
c158cba6
authored
Mar 16, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timestamps for wiki page metadata
parent
56b298f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
app/models/wiki_page/meta.rb
app/models/wiki_page/meta.rb
+11
-4
db/migrate/20200302152516_add_wiki_slug.rb
db/migrate/20200302152516_add_wiki_slug.rb
+2
-0
db/schema.rb
db/schema.rb
+4
-0
No files found.
app/models/wiki_page/meta.rb
View file @
c158cba6
...
...
@@ -74,9 +74,9 @@ class WikiPage
if
persisted?
transaction
do
slugs
.
update_all
(
canonical:
false
)
slugs
.
canonical
.
update_all
(
updated_at:
Time
.
now
,
canonical:
false
)
page_slug
=
slugs
.
create_with
(
canonical:
true
).
find_or_create_by
(
slug:
slug
)
page_slug
.
update_column
(
:canonical
,
true
)
unless
page_slug
.
canonical?
page_slug
.
update_column
s
(
canonical:
true
,
updated_at:
Time
.
now
)
unless
page_slug
.
canonical?
end
else
slugs
.
new
(
slug:
slug
,
canonical:
true
)
...
...
@@ -94,12 +94,19 @@ class WikiPage
private
def
update_wiki_page_attributes
(
page
)
update_column
(
:title
,
page
.
title
)
unless
page
.
title
==
title
update_column
s
(
title:
page
.
title
,
updated_at:
Time
.
now
)
unless
page
.
title
==
title
end
def
insert_slugs
(
strings
,
is_new
,
canonical_slug
)
creation
=
Time
.
now
slug_attrs
=
strings
.
map
do
|
slug
|
{
wiki_page_meta_id:
id
,
slug:
slug
,
canonical:
(
is_new
&&
slug
==
canonical_slug
)
}
{
wiki_page_meta_id:
id
,
slug:
slug
,
canonical:
(
is_new
&&
slug
==
canonical_slug
),
created_at:
creation
}
end
slugs
.
insert_all
(
slug_attrs
)
unless
!
is_new
&&
slug_attrs
.
size
==
1
...
...
db/migrate/20200302152516_add_wiki_slug.rb
View file @
c158cba6
...
...
@@ -6,12 +6,14 @@ class AddWikiSlug < ActiveRecord::Migration[6.0]
def
change
create_table
:wiki_page_meta
,
id: :serial
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
},
null:
false
t
.
timestamps_with_timezone
null:
false
,
default:
->
{
'NOW()'
}
t
.
string
:title
,
null:
false
,
limit:
255
end
create_table
:wiki_page_slugs
,
id: :serial
do
|
t
|
t
.
boolean
:canonical
,
default:
false
,
null:
false
t
.
references
:wiki_page_meta
,
index:
true
,
foreign_key:
{
on_delete: :cascade
},
null:
false
t
.
timestamps_with_timezone
null:
false
,
default:
->
{
'NOW()'
}
t
.
string
:slug
,
null:
false
,
limit:
2048
t
.
index
[
:slug
,
:wiki_page_meta_id
],
unique:
true
t
.
index
[
:wiki_page_meta_id
],
name:
'one_canonical_wiki_page_slug_per_metadata'
,
unique:
true
,
where:
"(canonical = true)"
...
...
db/schema.rb
View file @
c158cba6
...
...
@@ -4669,6 +4669,8 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
create_table
"wiki_page_meta"
,
id: :serial
,
force: :cascade
do
|
t
|
t
.
bigint
"project_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
default:
->
{
"now()"
},
null:
false
t
.
datetime_with_timezone
"updated_at"
,
default:
->
{
"now()"
},
null:
false
t
.
string
"title"
,
limit:
255
,
null:
false
t
.
index
[
"project_id"
],
name:
"index_wiki_page_meta_on_project_id"
end
...
...
@@ -4676,6 +4678,8 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
create_table
"wiki_page_slugs"
,
id: :serial
,
force: :cascade
do
|
t
|
t
.
boolean
"canonical"
,
default:
false
,
null:
false
t
.
bigint
"wiki_page_meta_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
default:
->
{
"now()"
},
null:
false
t
.
datetime_with_timezone
"updated_at"
,
default:
->
{
"now()"
},
null:
false
t
.
string
"slug"
,
limit:
2048
,
null:
false
t
.
index
[
"slug"
,
"wiki_page_meta_id"
],
name:
"index_wiki_page_slugs_on_slug_and_wiki_page_meta_id"
,
unique:
true
t
.
index
[
"wiki_page_meta_id"
],
name:
"index_wiki_page_slugs_on_wiki_page_meta_id"
...
...
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