プロジェクト

全般

プロフィール

Vote #72046

完了

Topics sort order is broken in Redmine 2.x

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Forums_5
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
5
version_id:
52
issue_org_id:
11170
author_id:
6870
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
50
ステータス-->[Closed]

説明

Because of Rails 3 by default uses order from has_many :order statement before any defined order, messages are always sorted by creation time first regardless of sticky attribute.

To fix it, line 46 in file app/controllers/boards_controller.rb


@topics =  @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
   :include => [:author, {:last_reply => :author}],
   :limit  =>  @topic_pages.items_per_page,
   :offset =>  @topic_pages.current.offset

should be changed to


@topics =  @board.topics.reorder(["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', ')).all(
   :include => [:author, {:last_reply => :author}],
   :limit  =>  @topic_pages.items_per_page,
   :offset =>  @topic_pages.current.offset)

journals

Why not move the sort order to the @has_many@ association declaration in source:/tags/2.0.2/app/models/board.rb#L21?
--------------------------------------------------------------------------------
Etienne Massip wrote:
> Why not move the sort order to the @has_many@ association declaration in source:/tags/2.0.2/app/models/board.rb#L21?

I am not sure why topics are sorted by creation time by default, but if it is does not matter - then yes, moving sticky sort order to association will simplify things a bit.
--------------------------------------------------------------------------------
Fixed in r9836, thanks for pointing this out.
We do not always want the messages in the same order (eg. board display vs. atom feed), so having this handled by the association sort order is not a better solution.
--------------------------------------------------------------------------------
Merged.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリForums_5 にセット
  • 対象バージョン2.0.3_52 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0