-
Notifications
You must be signed in to change notification settings - Fork 3
Sort time entries by name, not ID #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
time_columns = %w(tyear tmonth tweek spent_on) | ||
@hours = [] | ||
@scope.includes(:activity). | ||
reorder(nil). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここはソートが解除されますが、@scope
にクエリーで指定したのソート順が入っているので、それを適用すればいいのでは?
reorder(nil). | ||
group(@criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns). | ||
joins(@criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact). | ||
order(@criteria.collect{|criteria| @available_criteria[criteria][:order]}.compact). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
もう一度考えてみれば、ここは本当はこういう感じでやりたい
results = @scope.includes(:activity).
reorder(nil).
group(...).
joins(...)
@criteria.collect{|criteria| @available_criteria[criteria][:order]}.compact.each do |order_by_criteria|
results = order_by_criteria(results)
end
result.sum(:hours).each do |hash, hours|
...
orderの項目を変換するブロックにしたらいい
@available_criteria = {
'project' => {:sql => "#{TimeEntry.table_name}.project_id",
...
order: ->(results) { results.order("#{Project.table_name}.name") }
これで、joinsとか必要だった場合に、その「メソッド」の任せたらいい。
5344973
to
c7132d5
Compare
7721af8
to
b82bcac
Compare
9ec8c6c
to
4c7ddc1
Compare
439883b
to
7287657
Compare
4c7ddc1
to
308cef0
Compare
fb09dfd
to
a9c8777
Compare
308cef0
to
a737794
Compare
2bed14b
to
126c097
Compare
a737794
to
c410916
Compare
9bfd1ec
to
c94184b
Compare
4e3092f
to
c2523d4
Compare
3bd6e7f
to
4e02d13
Compare
f842c84
to
0fcefd7
Compare
fc59a89
to
0309f10
Compare
b963f59
to
96f43aa
Compare
0309f10
to
81eb59b
Compare
96f43aa
to
7a6d552
Compare
81eb59b
to
cd275c8
Compare
cd275c8
to
0b2649f
Compare
1a231c9
to
d3c012a
Compare
d3c012a
to
63bc3bd
Compare
63bc3bd
to
02f1476
Compare
02f1476
to
c287f07
Compare
Patch can be downloaded here |
@kfischer-okarin こちら、本家のIssueのその後の経緯を確認したところ、Yuichi HARADAさんが6ヶ月前から別のパッチを作成され、1ヶ月ほど前にtrunkにマージされ、次期メジャーバージョンでリリースされるようでした。 問題なさそうでしたら、こちらはクローズしようかと思いますので、よろしくお願いします。 |
Redmine Issue: https://www.redmine.org/issues/2848
Scrapbox Memo (Japanese): https://scrapbox.io/redmine-patch/%E7%AC%AC2%E5%9B%9E%2FSort(%232848)
Written in cooperation with Goh Matsumoto, Akiko Takano and akipii