https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292019-09-02T05:33:34ZRedmineRedmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934382019-09-02T05:33:34ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/31989">Feature #31989</a>: Inline issue auto complete (#) in fields with text-formatting enabled</i> added</li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934402019-09-02T05:46:00ZGo MAEDA
<ul></ul><p>What do you think if the patch checks params[:status] even when the search term is empty? I think it is more consistent.</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb
index f6a1414ad..bd8ce06b0 100644
</span><span class="gd">--- a/app/controllers/auto_completes_controller.rb
</span><span class="gi">+++ b/app/controllers/auto_completes_controller.rb
</span><span class="p">@@ -25,11 +25,10 @@</span> class AutoCompletesController < ApplicationController
q = (params[:q] || params[:term]).to_s.strip
status = params[:status].to_s
issue_id = params[:issue_id].to_s
<span class="gi">+
+ scope = Issue.cross_project_scope(@project, params[:scope]).visible
+ scope = scope.open(status == 'o') if status.present?
</span> if q.present?
<span class="gd">- scope = Issue.cross_project_scope(@project, params[:scope]).visible
- if status.present?
- scope = scope.open(status == 'o')
- end
</span> if issue_id.present?
scope = scope.where.not(:id => issue_id.to_i)
end
<span class="p">@@ -39,6 +38,8 @@</span> class AutoCompletesController < ApplicationController
issues += scope.like(q).order(:id => :desc).limit(10).to_a
issues.compact!
<span class="gi">+ else
+ issues += scope.order(:id => :desc).limit(10).to_a
</span> end
render :json => format_issues_json(issues)
</code></pre> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934412019-09-02T07:14:13ZMarius BĂLTEANU
<ul><li><strong>File</strong> deleted (<del><i>0001-Issue-auto-complete-should-return-last-10-updated-is.patch</i></del>)</li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934422019-09-02T07:16:03ZMarius BĂLTEANU
<ul><li><strong>File</strong> <a href="/attachments/23749">0001-Issue-auto-complete-should-return-last-10-updated-is.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/23749/0001-Issue-auto-complete-should-return-last-10-updated-is.patch">0001-Issue-auto-complete-should-return-last-10-updated-is.patch</a> added</li></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>What do you think if the patch checks params[:status] even when the search term is empty? I think it is more consistent.</p>
</blockquote>
<p>Very good idea, thanks! I've updated the patch, also <code>params[:issue_id]</code> should be outside.</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934432019-09-02T09:05:04ZGo MAEDA
<ul><li><strong>Target version</strong> set to <i>Candidate for next major release</i></li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=934492019-09-02T09:42:31ZGo MAEDA
<ul><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>4.1.0</i></li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936282019-09-09T22:00:02ZGo MAEDA
<ul><li><strong>Assignee</strong> set to <i>Marius BĂLTEANU</i></li></ul><p>The subject says "return last 10 updated issues" but actually the patch returns last 10 created issues. Is it OK?</p>
<pre><code class="ruby syntaxhl"> <span class="n">issues</span> <span class="o">+=</span> <span class="n">scope</span><span class="p">.</span><span class="nf">like</span><span class="p">(</span><span class="n">q</span><span class="p">).</span><span class="nf">order</span><span class="p">(</span><span class="ss">:id</span> <span class="o">=></span> <span class="ss">:desc</span><span class="p">).</span><span class="nf">limit</span><span class="p">(</span><span class="mi">10</span><span class="p">).</span><span class="nf">to_a</span>
</code></pre> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936412019-09-10T16:28:30ZMarius BĂLTEANU
<ul><li><strong>Subject</strong> changed from <i>Allow issue auto complete to return last 10 updated issues when there is not search term provided</i> to <i>Allow issue auto complete to return last 10 created issues when there is not search term provided</i></li><li><strong>Assignee</strong> changed from <i>Marius BĂLTEANU</i> to <i>Go MAEDA</i></li></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>The subject says "return last 10 updated issues" but actually the patch returns last 10 created issues. Is it OK?</p>
<p>[...]</p>
</blockquote>
<p>Indeed, my initial intention was to return the last 10 updated issues, but during the implementation, I kept the existing behaviour. I'm updating the issue subject because changing from last created to last updated (which I still consider a good idea) should be discussed in another ticket. Go Maeda, thanks for catching this.</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936422019-09-10T16:28:48ZMarius BĂLTEANU
<ul><li><strong>Subject</strong> changed from <i>Allow issue auto complete to return last 10 created issues when there is not search term provided</i> to <i>Allow issue auto complete to return 10 issues when there is not search term provided</i></li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936572019-09-11T07:16:38ZGo MAEDA
<ul></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>Second patch removes a view that is not used from my checks (code cleanup).</p>
</blockquote>
<p>app/views/auto_completes/issues.html.erb is no longer used after <a class="changeset" title="Issues autocomplete should response with content type json and not html (#30818). Patch by Mariu..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17881">r17881</a> (<code>render :layout => false</code> was replaced with <code>render :json => format_issues_json(issues)</code>).</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936582019-09-11T07:18:42ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li></ul><p>Committed the patches. Thank you for your contribution.</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936612019-09-11T17:36:41ZMischa The Evil
<ul></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>Go MAEDA wrote:</p>
<blockquote>
<p>The subject says "return last 10 updated issues" but actually the patch returns last 10 created issues. Is it OK?</p>
<p>[...]</p>
</blockquote>
<p>Indeed, my initial intention was to return the last 10 updated issues, but during the implementation, I kept the existing behaviour.</p>
</blockquote>
<p>Shouldn't this change be reflected in the name of the test that is committed (<code>test_auto_complete_without_term_should_return_last_10_updated_issues</code>)?</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936622019-09-11T19:44:00ZMarius BĂLTEANU
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Reopened</i></li></ul><p>Mischa The Evil wrote:</p>
<blockquote>
<p>Marius BALTEANU wrote:</p>
<blockquote>
<p>Go MAEDA wrote:</p>
<blockquote>
<p>The subject says "return last 10 updated issues" but actually the patch returns last 10 created issues. Is it OK?</p>
<p>[...]</p>
</blockquote>
<p>Indeed, my initial intention was to return the last 10 updated issues, but during the implementation, I kept the existing behaviour.</p>
</blockquote>
<p>Shouldn't this change be reflected in the name of the test that is committed (<code>test_auto_complete_without_term_should_return_last_10_updated_issues</code>)?</p>
</blockquote>
<p>Indeed, it should, sorry for it.</p>
<pre><code class="diff syntaxhl"><span class="p">Mariuss-MacBook-Pro:redmine mariusbalteanu$ git diff
</span><span class="gh">diff --git a/test/functional/auto_completes_controller_test.rb b/test/functional/auto_completes_controller_test.rb
index 825ebf8e9..f8ed441da 100644
</span><span class="gd">--- a/test/functional/auto_completes_controller_test.rb
</span><span class="gi">+++ b/test/functional/auto_completes_controller_test.rb
</span><span class="p">@@ -151,7 +151,7 @@</span> class AutoCompletesControllerTest < Redmine::ControllerTest
assert_include 'application/json', response.headers['Content-Type']
end
- def test_auto_complete_without_term_should_return_last_10_updated_issues
<span class="gi">+ def test_auto_complete_without_term_should_return_last_10_issues
</span> # There are 9 issues generated by fixtures
# and we need two more to test the 10 limit
%w(1..2).each do
</code></pre> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936642019-09-11T23:36:14ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Reopened</i> to <i>Closed</i></li></ul><p>Mischa The Evil wrote:</p>
<blockquote>
<p>Shouldn't this change be reflected in the name of the test that is committed (<code>test_auto_complete_without_term_should_return_last_10_updated_issues</code>)?</p>
</blockquote>
<p>Thank you for pointing it out. Committed the fix posted in <a class="issue tracker-3 status-5 priority-4 priority-default closed" title="Patch: Allow issue auto complete to return 10 issues when there is not search term provided (Closed)" href="https://www.redmine.org/issues/31994#note-12">#31994#note-12</a> in <a class="changeset" title="Fix the test name different from the actual behavior (#31994). Patch by Marius BALTEANU." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/18452">r18452</a>.</p> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936742019-09-12T08:44:01ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/32052">Feature #32052</a>: Auto-complete issues #id in search form</i> added</li></ul> Redmine - Patch #31994: Allow issue auto complete to return 10 issues when there is not search term providedhttps://www.redmine.org/issues/31994?journal_id=936772019-09-12T10:07:48ZGo MAEDA
<ul><li><strong>Related to</strong> deleted (<i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/32052">Feature #32052</a>: Auto-complete issues #id in search form</i>)</li></ul>