<p><b>@tomhughes</b> requested changes on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2381#discussion_r380826630">app/controllers/api/notes_controller.rb</a>:</p>
<pre style='color:#555'>> @@ -294,11 +294,25 @@ def search
raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
end
- @notes = @notes.where(:created_at => from..to)
+ @notes = params[:sort] == "created_at" ? @notes.where(:created_at => from..to) : @notes.where(:updated_at => from..to)
</pre>
<p>This will change the behaviour of existing API calls - you should make <code>created_at</code> the default to preserve the existing behaviour when no sort is specified.</p>
<p>I'd also prefer it if this was written like the sort order code with a multiline if rather than using the ternary operator, which is much less readable.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2381#discussion_r380827145">app/controllers/api/notes_controller.rb</a>:</p>
<pre style='color:#555'>> @@ -294,11 +294,25 @@ def search
raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
end
- @notes = @notes.where(:created_at => from..to)
+ @notes = params[:sort] == "created_at" ? @notes.where(:created_at => from..to) : @notes.where(:updated_at => from..to)
end
# Find the notes we want to return
</pre>
<p>This comment should be moved down to stay with the line it was originally attached to as it's incorrect where it is now.</p>
<p>If you want a comment here then it should say <code>Chose the sort order</code> or something.</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/2381?email_source=notifications&email_token=AAK2OLJJIBEYN2EWCK53UV3RDQL6VA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCV6VOJY#pullrequestreview-360535847">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLJMFPLTW75CC6QAPILRDQL6VANCNFSM4I5CYR2A">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLJNZZSCQOTVWHGPJFTRDQL6VA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCV6VOJY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2381?email_source=notifications\u0026email_token=AAK2OLJJIBEYN2EWCK53UV3RDQL6VA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCV6VOJY#pullrequestreview-360535847",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2381?email_source=notifications\u0026email_token=AAK2OLJJIBEYN2EWCK53UV3RDQL6VA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCV6VOJY#pullrequestreview-360535847",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>