<p><b>@mmd-osm</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/1995#discussion_r222242460">app/models/node.rb</a>:</p>
<pre style='color:#555'>> @@ -164,6 +172,65 @@ def delete_with_history!(new_node, user)
     end
   end
 
+  def self.delete_with_history_bulk!(nodes, changeset, if_unused = false)
+    node_hash = nodes.collect { |node| [node.id, node] }.to_h
+    skipped = {}
+    Node.transaction do
+      # check if node ids exists
+      node_ids = node_hash.keys
+      old_nodes = Node.select("id, version, visible").where(:id => node_ids).lock
+      raise OSM::APIBadUserInput, "Node not exist. id: " + (node_ids - old_nodes.collect(&:id)).join(", ") unless node_ids.length == old_nodes.length
</pre>
<p>Non-existing object should return HTTP 404 (Not found) instead of HTTP 400 (Bad Request)</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/1995#discussion_r222242700">app/models/relation.rb</a>:</p>
<pre style='color:#555'>> @@ -207,6 +218,54 @@ def delete_with_history!(new_relation, user)
     end
   end
 
+  def self.delete_with_history_bulk!(relations, changeset, if_unused = false)
+    relation_hash = relations.collect { |r| [r.id, r] }.to_h
+    skipped = {}
+    # need to start the transaction here, so that the database can
+    # provide repeatable reads for the used-by checks. this means it
+    # shouldn't be possible to get race conditions.
+    Relation.transaction do
+      relation_ids = relation_hash.keys
+      old_relations = Relation.select("id, version, visible").where(:id => relation_ids).lock
+      raise OSM::APIBadUserInput, "Relation not exist. id: " + (relation_ids - old_relations.collect(&:id)).join(", ") unless relation_ids.length == old_relations.length
</pre>
<p>Non-existing object should return HTTP 404 (Not found) instead of HTTP 400 (Bad Request)</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/1995#discussion_r222243018">app/models/way.rb</a>:</p>
<pre style='color:#555'>> @@ -248,6 +300,55 @@ def delete_with_history!(new_way, user)
     end
   end
 
+  def self.delete_with_history_bulk!(ways, changeset, if_unused = false)
+    way_hash = ways.collect { |way| [way.id, way] }.to_h
+    skipped = {}
+    # need to start the transaction here, so that the database can
+    # provide repeatable reads for the used-by checks. this means it
+    # shouldn't be possible to get race conditions.
+    Way.transaction do
+      way_ids = way_hash.keys
+      old_ways = Way.select("id, version, visible").where(:id => way_ids).lock
+      raise OSM::APIBadUserInput, "Way not exist. id: " + (way_ids - old_ways.collect(&:id)).join(", ") unless way_ids.length == old_ways.length
</pre>
<p>Non-existing object should return HTTP 404 (Not found) instead of HTTP 400 (Bad Request)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/1995#pullrequestreview-161078984">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLXDsQFAty_k_lyR-Eub9AXuvcNiUks5uhIQ_gaJpZM4WsA9n">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLYCEMTcBLfyCPsVWWp3RmSZI7yHMks5uhIQ_gaJpZM4WsA9n.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"PERSON","message":"@mmd-osm commented on #1995"}],"action":{"name":"View Pull Request","url":"https://github.com/openstreetmap/openstreetmap-website/pull/1995#pullrequestreview-161078984"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/1995#pullrequestreview-161078984",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/1995#pullrequestreview-161078984",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "@mmd-osm commented on 1995",
"sections": [
{
"text": "",
"activityTitle": "**mmd**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@mmd-osm",
"facts": [

]
}
],
"potentialAction": [
{
"targets": [
{
"os": "default",
"uri": "https://github.com/openstreetmap/openstreetmap-website/pull/1995#pullrequestreview-161078984"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 380637031\n}"
}
],
"themeColor": "26292E"
}
]</script>