summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-28 08:27:21 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-28 08:27:21 +0000
commit4576d55f44cfec6d6cab0df063ae9c26824222dd (patch)
treef66d553cb3f8489d76ba9789b55cb52d9e4fc721 /app
parentfe641cbd6a7d2e0598cdc34b50ad683ee078af84 (diff)
parent72544449cfb8e35b8c044f5bfd08a2fae2253408 (diff)
downloadgitlab-ce-4576d55f44cfec6d6cab0df063ae9c26824222dd.tar.gz
Merge branch 'id-change-total-notes-calculation' into 'master'
Change the way totalNotes is calculated See merge request gitlab-org/gitlab-ce!32191
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/notes/components/notes_app.vue4
-rw-r--r--app/helpers/notes_helper.rb4
-rw-r--r--app/models/concerns/noteable.rb4
3 files changed, 9 insertions, 3 deletions
diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue
index a0695f9e191..16a0fb3f33a 100644
--- a/app/assets/javascripts/notes/components/notes_app.vue
+++ b/app/assets/javascripts/notes/components/notes_app.vue
@@ -75,9 +75,9 @@ export default {
},
allDiscussions() {
if (this.isLoading) {
- const totalNotes = parseInt(this.notesData.totalNotes, 10) || 0;
+ const prerenderedNotesCount = parseInt(this.notesData.prerenderedNotesCount, 10) || 0;
- return new Array(totalNotes).fill({
+ return new Array(prerenderedNotesCount).fill({
isSkeletonNote: true,
});
}
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index 2e31a5e2ed4..4e88b379e16 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
module NotesHelper
+ MAX_PRERENDERED_NOTES = 10
+
def note_target_fields(note)
if note.noteable
hidden_field_tag(:target_type, note.noteable.class.name.underscore) +
@@ -169,7 +171,7 @@ module NotesHelper
closePath: close_issuable_path(issuable),
reopenPath: reopen_issuable_path(issuable),
notesPath: notes_url,
- totalNotes: issuable.discussions.length,
+ prerenderedNotesCount: issuable.capped_notes_count(MAX_PRERENDERED_NOTES),
lastFetchedAt: Time.now.to_i
}
end
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb
index 4b428b0af83..6a44bc7c401 100644
--- a/app/models/concerns/noteable.rb
+++ b/app/models/concerns/noteable.rb
@@ -73,6 +73,10 @@ module Noteable
.discussions(self)
end
+ def capped_notes_count(max)
+ notes.limit(max).count
+ end
+
def grouped_diff_discussions(*args)
# Doesn't use `discussion_notes`, because this may include commit diff notes
# besides MR diff notes, that we do not want to display on the MR Changes tab.