Add changeset comment search api with filtering by author and time

This commit is contained in:
Anton Khorev 2023-11-16 10:03:26 +03:00
parent bd278a07fe
commit 1f59507e78
8 changed files with 91 additions and 14 deletions

View file

@ -0,0 +1,12 @@
cattrs = {
"id" => changeset_comment.id,
"date" => changeset_comment.created_at.xmlschema,
"visible" => changeset_comment.visible
}
if changeset_comment.author.data_public?
cattrs["uid"] = changeset_comment.author.id
cattrs["user"] = changeset_comment.author.display_name
end
xml.comment(cattrs) do |comment_xml_node|
comment_xml_node.text(changeset_comment.body)
end

View file

@ -0,0 +1,7 @@
xml.instruct! :xml, :version => "1.0"
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
@comments.includes(:author).each do |comment|
osm << render(comment)
end
end

View file

@ -27,18 +27,7 @@ xml.changeset(attrs) do |changeset_xml_node|
if @comments
changeset_xml_node.discussion do |discussion_xml_node|
@comments.each do |comment|
cattrs = {
"id" => comment.id,
"date" => comment.created_at.xmlschema,
"visible" => comment.visible
}
if comment.author.data_public?
cattrs["uid"] = comment.author.id
cattrs["user"] = comment.author.display_name
end
discussion_xml_node.comment(cattrs) do |comment_xml_node|
comment_xml_node.text(comment.body)
end
discussion_xml_node << render(comment)
end
end
end