Skip to content

Commit a92575e

Browse files
Use distinct(*) on aggregated journal to avoid duplicate raw journals
https://community.openproject.com/wp/33744
1 parent d804372 commit a92575e

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

app/models/journal/aggregated_journal.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def containing_journal(pure_journal)
6363
# The +until_version+ parameter can be used in conjunction with the +journable+ parameter
6464
# to see the aggregated journals as if no versions were known after the specified version.
6565
def aggregated_journals(journable: nil, sql: nil, until_version: nil, includes: [])
66-
raw_journals = Journal::Scopes::AggregatedJournal.fetch(journable: journable, sql: sql, until_version: until_version)
66+
raw_journals = Journal::Scopes::AggregatedJournal
67+
.fetch(journable: journable, sql: sql, until_version: until_version)
68+
.order('version ASC')
6769

6870
aggregated_journals = map_to_aggregated_journals(raw_journals)
6971
preload_associations(journable, aggregated_journals, includes)

app/models/journal/scopes/aggregated_journal.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def fetch(journable: nil, sql: nil, until_version: nil)
4141
# having to also use a CASE/COALESCE statement.
4242
Journal
4343
.from(select_sql(journals_preselection))
44+
.select("DISTINCT *")
4445
end
4546

4647
private

spec/features/work_packages/details/markdown/activity_comments_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,34 @@
6868

6969
expect(page).to have_selector('.user-comment > .message', count: 3)
7070
wp_page.expect_comment text: 'this is my second comment!1'
71+
72+
expect(comment_field.editing?).to be false
73+
comment_field.activate!
74+
expect(comment_field.editing?).to be true
75+
76+
comment_field.click_and_type_slowly 'this is my third comment!1'
77+
comment_field.submit_by_click
78+
79+
# Only shows three most recent
80+
expect(page).to have_selector('.user-comment > .message', count: 3)
81+
wp_page.expect_comment text: 'this is my third comment!1'
82+
83+
wp_page.switch_to_tab tab: 'Activity'
84+
# Now showing all comments
85+
expect(page).to have_selector('.user-comment > .message', count: 4, wait: 10)
86+
87+
expect(comment_field.editing?).to be false
88+
comment_field.activate!
89+
expect(comment_field.editing?).to be true
90+
91+
comment_field.click_and_type_slowly 'this is my fifth comment!1'
92+
comment_field.submit_by_click
93+
94+
expect(page).to have_selector('.user-comment > .message', count: 4)
95+
wp_page.expect_comment text: 'this is my fifth comment!1'
96+
97+
# Expect no activity details
98+
expect(page).to have_no_selector('.work-package-details-activities-messages li')
7199
end
72100
end
73101

0 commit comments

Comments
 (0)