Skip to content

Commit 20e9485

Browse files
authoredApr 11, 2024
Merge pull request zerebubuth#388 from mmd-osm/patch/cs_comments_omit
Skip changeset discussions unless requested
2 parents 92a4e49 + 0f18004 commit 20e9485

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed
 

‎src/backend/apidb/common_pgsql_selection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void extract_changesets(
458458
for (const auto &row : rows) {
459459
auto elem = extract_changeset(row, cc, changeset_cols);
460460
auto tags = extract_tags(row, tag_cols);
461-
auto comments = extract_comments(row, comments_cols);
461+
auto comments = (include_changeset_discussions ? extract_comments(row, comments_cols) : comments_t{});
462462
elem.comments_count = comments.size();
463463
formatter.write_changeset(
464464
elem, tags, include_changeset_discussions, comments, now);

‎src/backend/apidb/readonly_pgsql_selection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ void readonly_pgsql_selection::write_changesets(output_formatter &formatter,
362362
"to_char(cc.created_at,'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') AS created_at "
363363
"FROM changeset_comments cc JOIN users u ON cc.author_id = u.id "
364364
"where cc.changeset_id=c.id AND cc.visible ORDER BY cc.created_at) x "
365-
")cc ON true "
365+
")cc ON $2 "
366366
"WHERE c.id = ANY($1)");
367367

368-
pqxx::result changesets = m.exec_prepared("extract_changesets", sel_changesets);
368+
pqxx::result changesets = m.exec_prepared("extract_changesets", sel_changesets, include_changeset_discussions);
369369

370370
fetch_changesets(sel_changesets, cc);
371371

‎test/test_apidb_backend_changesets.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ void check_changeset_with_comments_impl(
290290
REQUIRE(f.m_changesets.size() == 1);
291291

292292
comments_t comments;
293-
{
293+
294+
if (include_discussion) {
294295
changeset_comment_info comment;
295296
comment.id = 1;
296297
comment.author_id = 3;
@@ -311,7 +312,7 @@ void check_changeset_with_comments_impl(
311312
std::string("user_1"), // display_name
312313
{}, // bounding box
313314
0, // num_changes
314-
1 // comments_count
315+
include_discussion ? 1 : 0 // comments_count
315316
),
316317
tags_t(),
317318
include_discussion,

0 commit comments

Comments
 (0)
Failed to load comments.