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
b21f9db2
Commit
b21f9db2
authored
Jan 22, 2022
by
Jonas Wälter
Committed by
Peter Leitzen
Jan 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `Project.updated_at` if other timestamps change
Changelog: fixed
parent
ac5eb557
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
13 deletions
+15
-13
app/models/event.rb
app/models/event.rb
+2
-2
lib/gitlab/github_import/importer/pull_requests_importer.rb
lib/gitlab/github_import/importer/pull_requests_importer.rb
+1
-1
lib/gitlab/github_import/importer/repository_importer.rb
lib/gitlab/github_import/importer/repository_importer.rb
+1
-1
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
...gitlab/github_import/importer/repository_importer_spec.rb
+2
-2
spec/models/event_spec.rb
spec/models/event_spec.rb
+9
-7
No files found.
app/models/event.rb
View file @
b21f9db2
...
@@ -354,7 +354,7 @@ class Event < ApplicationRecord
...
@@ -354,7 +354,7 @@ class Event < ApplicationRecord
# hence we add the extra WHERE clause for last_activity_at.
# hence we add the extra WHERE clause for last_activity_at.
Project
.
unscoped
.
where
(
id:
project_id
)
Project
.
unscoped
.
where
(
id:
project_id
)
.
where
(
'last_activity_at <= ?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
)
.
where
(
'last_activity_at <= ?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
)
.
update_all
(
last_activity_at:
created_at
)
.
touch_all
(
:last_activity_at
,
time:
created_at
)
# rubocop: disable Rails/SkipsModelValidations
end
end
def
authored_by?
(
user
)
def
authored_by?
(
user
)
...
@@ -430,7 +430,7 @@ class Event < ApplicationRecord
...
@@ -430,7 +430,7 @@ class Event < ApplicationRecord
def
set_last_repository_updated_at
def
set_last_repository_updated_at
Project
.
unscoped
.
where
(
id:
project_id
)
Project
.
unscoped
.
where
(
id:
project_id
)
.
where
(
"last_repository_updated_at < ? OR last_repository_updated_at IS NULL"
,
REPOSITORY_UPDATED_AT_INTERVAL
.
ago
)
.
where
(
"last_repository_updated_at < ? OR last_repository_updated_at IS NULL"
,
REPOSITORY_UPDATED_AT_INTERVAL
.
ago
)
.
update_all
(
last_repository_updated_at:
created_at
)
.
touch_all
(
:last_repository_updated_at
,
time:
created_at
)
# rubocop: disable Rails/SkipsModelValidations
end
end
def
design_action_names
def
design_action_names
...
...
lib/gitlab/github_import/importer/pull_requests_importer.rb
View file @
b21f9db2
...
@@ -38,7 +38,7 @@ module Gitlab
...
@@ -38,7 +38,7 @@ module Gitlab
# deliberate. If we were to update this column after the fetch we may
# deliberate. If we were to update this column after the fetch we may
# miss out on changes pushed during the fetch or between the fetch and
# miss out on changes pushed during the fetch or between the fetch and
# updating the timestamp.
# updating the timestamp.
project
.
update_column
(
:last_repository_updated_at
,
Time
.
zone
.
now
)
project
.
touch
(
:last_repository_updated_at
)
# rubocop: disable Rails/SkipsModelValidations
project
.
repository
.
fetch_remote
(
project
.
import_url
,
refmap:
Gitlab
::
GithubImport
.
refmap
,
forced:
false
)
project
.
repository
.
fetch_remote
(
project
.
import_url
,
refmap:
Gitlab
::
GithubImport
.
refmap
,
forced:
false
)
...
...
lib/gitlab/github_import/importer/repository_importer.rb
View file @
b21f9db2
...
@@ -80,7 +80,7 @@ module Gitlab
...
@@ -80,7 +80,7 @@ module Gitlab
end
end
def
update_clone_time
def
update_clone_time
project
.
update_column
(
:last_repository_updated_at
,
Time
.
zone
.
now
)
project
.
touch
(
:last_repository_updated_at
)
# rubocop: disable Rails/SkipsModelValidations
end
end
private
private
...
...
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
View file @
b21f9db2
...
@@ -264,8 +264,8 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do
...
@@ -264,8 +264,8 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do
it
'sets the timestamp for when the cloning process finished'
do
it
'sets the timestamp for when the cloning process finished'
do
freeze_time
do
freeze_time
do
expect
(
project
)
expect
(
project
)
.
to
receive
(
:
update_column
)
.
to
receive
(
:
touch
)
.
with
(
:last_repository_updated_at
,
Time
.
zone
.
now
)
.
with
(
:last_repository_updated_at
)
importer
.
update_clone_time
importer
.
update_clone_time
end
end
...
...
spec/models/event_spec.rb
View file @
b21f9db2
...
@@ -31,14 +31,15 @@ RSpec.describe Event do
...
@@ -31,14 +31,15 @@ RSpec.describe Event do
describe
'after_create :set_last_repository_updated_at'
do
describe
'after_create :set_last_repository_updated_at'
do
context
'with a push event'
do
context
'with a push event'
do
it
'updates the project last_repository_updated_at'
do
it
'updates the project last_repository_updated_at
and updated_at
'
do
project
.
update!
(
last_repository_updated_at:
1
.
year
.
ago
)
project
.
touch
(
:last_repository_updated_at
,
time:
1
.
year
.
ago
)
# rubocop: disable Rails/SkipsModelValidations
create_push_event
(
project
,
project
.
owner
)
event
=
create_push_event
(
project
,
project
.
owner
)
project
.
reload
project
.
reload
expect
(
project
.
last_repository_updated_at
).
to
be_within
(
1
.
minute
).
of
(
Time
.
current
)
expect
(
project
.
last_repository_updated_at
).
to
be_like_time
(
event
.
created_at
)
expect
(
project
.
updated_at
).
to
be_like_time
(
event
.
created_at
)
end
end
end
end
...
@@ -835,13 +836,14 @@ RSpec.describe Event do
...
@@ -835,13 +836,14 @@ RSpec.describe Event do
context
'when a project was updated more than 1 hour ago'
do
context
'when a project was updated more than 1 hour ago'
do
it
'updates the project'
do
it
'updates the project'
do
project
.
update!
(
last_activity_at:
1
.
year
.
ago
)
project
.
touch
(
:last_activity_at
,
time:
1
.
year
.
ago
)
# rubocop: disable Rails/SkipsModelValidations
create_push_event
(
project
,
project
.
owner
)
event
=
create_push_event
(
project
,
project
.
owner
)
project
.
reload
project
.
reload
expect
(
project
.
last_activity_at
).
to
be_within
(
1
.
minute
).
of
(
Time
.
current
)
expect
(
project
.
last_activity_at
).
to
be_like_time
(
event
.
created_at
)
expect
(
project
.
updated_at
).
to
be_like_time
(
event
.
created_at
)
end
end
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