<p></p>
<p><b>@tomhughes</b> requested changes on this pull request.</p>

<p dir="auto">Overall the big difference between <code class="notranslate">import!</code> and <code class="notranslate">insert_all!</code> is that the former runs validations and the latter does not so maybe if we're going to change we should run <code class="notranslate">validate!</code> on each point after it is created?</p>
<p dir="auto">Really the ideal way to use <code class="notranslate">insert_all!</code> would be not to build the models at all and just build a list of hashes but as it stands we need to run the save callbacks to fill in the tile number...</p><hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5038#discussion_r1703153974">.rubocop.yml</a>:</p>
<pre style='color:#555'>> @@ -71,6 +71,7 @@ Rails/SkipsModelValidations:
   Exclude:
     - 'db/migrate/*.rb'
     - 'app/controllers/users_controller.rb'
+    - 'app/models/trace.rb'
</pre>
<p dir="auto">Why do we need to exclude this?</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5038#discussion_r1703156521">app/models/trace.rb</a>:</p>
<pre style='color:#555'>>          tracepoints.each do |tp|
           tp.run_callbacks(:save) { false }
           tp.run_callbacks(:create) { false }
         end
 
-        Tracepoint.import!(tracepoints)
+        Tracepoint.insert_all!(tracepoints.map(&:attributes))
</pre>
<p dir="auto">I've done some testing and I think this looks right - my main concern is the timestamp column as <code class="notranslate">attributes</code> returns it in string form.</p>
<p dir="auto">It would probably be a good idea to add a test to the trace model tests that imports <code class="notranslate">a.gpx</code> and checks that the one point it imports has the expected values for each attribute as we don't seem to have one that checks the imported data at the moment.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5038#pullrequestreview-2217654589">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLNHAAYKYHLCMWJVJ4TZPYGVVAVCNFSM6AAAAABL3DDMS6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEMJXGY2TINJYHE">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLIGN4EVTTL5JQZARXDZPYGVVA5CNFSM6AAAAABL3DDMS6WGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUEF24T2.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5038/review/2217654589</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5038#pullrequestreview-2217654589",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5038#pullrequestreview-2217654589",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>