]> git.openstreetmap.org Git - rails.git/blob - app/views/api/changesets/_changeset.json.jbuilder
expose the enhanced changeset stats via the API
[rails.git] / app / views / api / changesets / _changeset.json.jbuilder
1 # frozen_string_literal: true
2
3 # basic attributes
4 json.id changeset.id
5 json.created_at changeset.created_at.xmlschema
6 json.open changeset.open?
7 json.comments_count changeset.comments.length
8 json.changes_count changeset.num_changes
9 json.created_count changeset.num_created_elements
10 json.modified_count changeset.num_modified_elements
11 json.deleted_count changeset.num_deleted_elements
12
13 json.closed_at changeset.closed_at.xmlschema unless changeset.open?
14 if changeset.bbox.complete?
15   json.min_lat GeoRecord::Coord.new(changeset.bbox.to_unscaled.min_lat)
16   json.min_lon GeoRecord::Coord.new(changeset.bbox.to_unscaled.min_lon)
17   json.max_lat GeoRecord::Coord.new(changeset.bbox.to_unscaled.max_lat)
18   json.max_lon GeoRecord::Coord.new(changeset.bbox.to_unscaled.max_lon)
19 end
20
21 # user attributes
22 if changeset.user.data_public?
23   json.uid changeset.user_id
24   json.user changeset.user.display_name
25 end
26
27 json.tags changeset.tags unless changeset.tags.empty?
28
29 if @comments
30   json.comments(@comments) do |comment|
31     json.partial! comment
32   end
33 end