<p>I've had a look through this today. It's a large and complex PR touching one of the most complex parts of the codebase, so it's hard to review. But I want to say that I completely support the idea of refactoring the changeset upload processing to import entities in bulk, in order to improve performance.</p>
<p>I've merged with the current master and fixed the conflicts, since there's been some controller refactoring since this PR was made. You can see the results at <a href="https://github.com/gravitystorm/openstreetmap-website/tree/changeset_bulk">https://github.com/gravitystorm/openstreetmap-website/tree/changeset_bulk</a> . I haven't updated this PR, since the tests no longer pass.</p>
<p>It turns out that there is a problem somewhere between this PR and the updated version of <a href="https://github.com/zdennis/activerecord-import">activerecord-import</a> that we are now using. This PR uses <code>v0.25.0</code> and we now use <code>v1.0.1</code>. I think it's caused by our use of <a href="https://github.com/composite-primary-keys/composite_primary_keys">composite-primary-keys</a> which allows belongs_to relations to have a foreign key specified as an array instead of a string, e.g.</p>
<pre><code>belongs_to :old_node, :foreign_key => [:node_id, :version]
</code></pre>
<p>activerecord-import then blows up <a href="https://github.com/zdennis/activerecord-import/blob/38cc26b21969a7c76a3e5b88cb79d6591ee09035/lib/activerecord-import/import.rb#L51">when trying to convert this array to a symbol</a>. This <a href="https://github.com/zdennis/activerecord-import/commit/3e7cd50eac766c09fb8b1ff5f372459248ae2bd1">was introduced</a> in activerecord-import <code>0.28.1</code>.</p>
<p>So I think there are two things that we should work on here now:</p>
<ol>
<li>
<p>Extract the additional changeset upload tests into their own PR. They contain useful checks that <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=5842757" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mmd-osm">@mmd-osm</a> and <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=14369148" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jiaxuyang">@jiaxuyang</a> worked on as part of this PR, and will come in useful at some point even if this PR isn't merged.</p>
</li>
<li>
<p>Figure out the best way forward with this foreign key problem. This could involve a combination of</p>
<ul>
<li>rewriting this PR</li>
<li>changes to activerecord-import to restore compatibility with composite-primary-keys</li>
<li>rewriting this PR to work with the <a href="https://github.com/rails/rails/commit/91ed21b304c468db8ce9fd830312c151432935d0">upcoming rails 6 "insert_all"</a></li>
<li>something else entirely</li>
</ul>
</li>
</ol>

<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#issuecomment-479501602">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLfc4V0FIk8XYVpNTaMUf-IToU11iks5vdLO-gaJpZM4WsA9n">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLZqmTvx_z7G8_HkEEZcqbJ5B18GPks5vdLO-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://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"PERSON","message":"@gravitystorm in #1995: I've had a look through this today. It's a large and complex PR touching one of the most complex parts of the codebase, so it's hard to review. But I want to say that I completely support the idea of refactoring the changeset upload processing to import entities in bulk, in order to improve performance.\r\n\r\nI've merged with the current master and fixed the conflicts, since there's been some controller refactoring since this PR was made. You can see the results at https://github.com/gravitystorm/openstreetmap-website/tree/changeset_bulk . I haven't updated this PR, since the tests no longer pass.\r\n\r\nIt turns out that there is a problem somewhere between this PR and the updated version of [activerecord-import](https://github.com/zdennis/activerecord-import) that we are now using. This PR uses `v0.25.0` and we now use `v1.0.1`. I think it's caused by our use of [composite-primary-keys](https://github.com/composite-primary-keys/composite_primary_keys) which allows belongs_to relations to have a foreign key specified as an array instead of a string, e.g. \r\n\r\n```\r\nbelongs_to :old_node, :foreign_key =\u003e [:node_id, :version]\r\n```\r\nactiverecord-import then blows up [when trying to convert this array to a symbol](https://github.com/zdennis/activerecord-import/blob/38cc26b21969a7c76a3e5b88cb79d6591ee09035/lib/activerecord-import/import.rb#L51). This [was introduced](https://github.com/zdennis/activerecord-import/commit/3e7cd50eac766c09fb8b1ff5f372459248ae2bd1) in activerecord-import `0.28.1`.\r\n\r\nSo I think there are two things that we should work on here now:\r\n\r\n1) Extract the additional changeset upload tests into their own PR. They contain useful checks that @mmd-osm and @jiaxuyang worked on as part of this PR, and will come in useful at some point even if this PR isn't merged.\r\n\r\n2) Figure out the best way forward with this foreign key problem. This could involve a combination of \r\n    * rewriting this PR\r\n    * changes to activerecord-import to restore compatibility with composite-primary-keys\r\n    * rewriting this PR to work with the [upcoming rails 6 \"insert_all\"](https://github.com/rails/rails/commit/91ed21b304c468db8ce9fd830312c151432935d0)\r\n    * something else entirely"}],"action":{"name":"View Pull Request","url":"https://github.com/openstreetmap/openstreetmap-website/pull/1995#issuecomment-479501602"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/1995#issuecomment-479501602",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/1995#issuecomment-479501602",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>