Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include changeset discussion comment ids in changeset replication files #680

Open
Woazboat opened this issue Jul 17, 2024 · 1 comment
Open

Comments

@Woazboat
Copy link

Opening an issue here since the replicate-changesets script is seemingly maintained in here instead of in https://github.com/zerebubuth/openstreetmap-changeset-replication
(upstream issue: zerebubuth/openstreetmap-changeset-replication#9)


The OSM API recently changed the changeset endpoint to also return the comment id for changeset discussion comments in the api response. The changeset replication should probably be updated to also include this.
openstreetmap/openstreetmap-website#4245

<osm ...>
	<changeset ...>
		...
		<discussion>
			<comment id="1234" ...>
				<text>...</text>
			</comment>
			...
		</discussion>
	</changeset>
</osm>

def add_comments(xml, cs)
# grab the visible changeset comments as well
res = @conn.exec("select cc.author_id, u.display_name as author, cc.body, cc.created_at from changeset_comments cc join users u on cc.author_id=u.id where cc.changeset_id=#{cs.id} and cc.visible order by cc.created_at asc")
xml["comments_count"] = res.num_tuples.to_s
# early return if there aren't any comments
return unless res.num_tuples.positive?
discussion = XML::Node.new("discussion")
res.each do |row|
comment = XML::Node.new("comment")
comment["uid"] = row["author_id"]
comment["user"] = xml_sanitize(row["author"])
comment["date"] = Time.parse(row["created_at"]).getutc.xmlschema
text = XML::Node.new("text")
text.content = xml_sanitize(row["body"])
comment << text
discussion << comment
end
xml << discussion
end
end

@tomhughes
Copy link
Member

Looking at the history here I don't think I was aware that other repo existed - it looks like I found the script running unmanaged on the server and added it here to get it managed without realising there was already a repo for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants