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
# hence we add the extra WHERE clause for last_activity_at.
Project
.
unscoped
.
where
(
id:
project_id
)
.
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
def
authored_by?
(
user
)
...
...
@@ -430,7 +430,7 @@ class Event < ApplicationRecord
def
set_last_repository_updated_at
Project
.
unscoped
.
where
(
id:
project_id
)
.
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
def
design_action_names
...
...
lib/gitlab/github_import/importer/pull_requests_importer.rb
View file @
b21f9db2
...
...
@@ -38,7 +38,7 @@ module Gitlab
# 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
# 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
)
...
...
lib/gitlab/github_import/importer/repository_importer.rb
View file @
b21f9db2
...
...
@@ -80,7 +80,7 @@ module Gitlab
end
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
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
it
'sets the timestamp for when the cloning process finished'
do
freeze_time
do
expect
(
project
)
.
to
receive
(
:
update_column
)
.
with
(
:last_repository_updated_at
,
Time
.
zone
.
now
)
.
to
receive
(
:
touch
)
.
with
(
:last_repository_updated_at
)
importer
.
update_clone_time
end
...
...
spec/models/event_spec.rb
View file @
b21f9db2
...
...
@@ -31,14 +31,15 @@ RSpec.describe Event do
describe
'after_create :set_last_repository_updated_at'
do
context
'with a push event'
do
it
'updates the project last_repository_updated_at'
do
project
.
update!
(
last_repository_updated_at:
1
.
year
.
ago
)
it
'updates the project last_repository_updated_at
and updated_at
'
do
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
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
...
...
@@ -835,13 +836,14 @@ RSpec.describe Event do
context
'when a project was updated more than 1 hour ago'
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
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
...
...
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