ラベル redmine の投稿を表示しています。 すべての投稿を表示
ラベル redmine の投稿を表示しています。 すべての投稿を表示

2008年4月7日月曜日

Redmineの工数詳細を100件に制限

工数登録が多くなると表示がかなり遅くなるので、
100 件で制限しておく。
全部表示したい場合は csv を指定すれば OK。

=====================================
app/controllers/timelog_controller.rb
=====================================

def details
sort_init 'spent_on', 'desc'
sort_update

####### 変更開始
#@entries = (@issue ? @issue : @project).time_entries.find(:all, :include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :order => sort_clause)
find_param = [:all, {:include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :order => sort_clause}]
if 'csv' != params[:export]
find_param[1][:limit] = 100
end
@entries = (@issue ? @issue : @project).time_entries.find(*find_param)
####### ここまで

@total_hours = @entries.inject(0) { |sum,entry| sum + entry.hours }
@owner_id = User.current.id

send_csv and return if 'csv' == params[:export]
render :action => 'details', :layout => false if request.xhr?
end

Redmineに工数確認機能を追加2

工数入力は同じ課題がしばらく続くことが多いので、
入力補助として履歴に最近入力した課題への工数入力のリンクを増やしてみた。

----------------------------------------
app/views/my/blocks/_hourhistories.rhtml
----------------------------------------
<h3>入力工数履歴</h3>

<ul>
<% sql =
"select user_id, spent_on, sum(hours) as day_hour" +
" from time_entries" +
" where user_id = #{user.id}" +
" group by spent_on" +
" order by spent_on desc" +
" limit 5"-%>
<% for entry in TimeEntry.find_by_sql(sql) %>
<li><%= "#{entry.spent_on}: #{entry.day_hour} h" %>
<% end %>
</ul>

<%= link_to "詳細", :controller => "man_hour" %>
<p>
<% sql =
"select distinct issue_id " +
" from time_entries" +
" where user_id = #{user.id}" +
" order by spent_on desc" +
" limit 10"-%>
<h3>最近工数入力した課題</h3>
<ul>
<% i = 0 %>
<% for entry in TimeEntry.find_by_sql(sql) %>
<% if entry.issue %>
<li>[<%= link_to '工数入力', :controller => 'timelog', :action => 'edit', :issue_id => entry.issue_id %>]
<%= link_to_issue entry.issue %> <%= entry.issue.subject %>
<% end %>
<% end %>
</ul>

2008年1月15日火曜日

Redmineに機能追加(終了済み Issue をカレンダーで取り消し線)


--------------------------------
app/views/common/_calendar.rhtml
--------------------------------
<%= h("#{i.project.name} -") unless @project && @project == i.project %>
<%= link_to_issue i %>: <!-- 元の処理 %= h(truncate(i.subject, 30)) % -->
<!-- 追加開始 -->
<%= '<del>' if i.closed? %><%= h(truncate(i.subject, 30)) %><%= '</del>' if i.closed? %>
<!-- ここまで -->
<span class="tip"><%= render_issue_tooltip i %></span>

2008年1月14日月曜日

Redmineに工数確認機能を追加

Redmine で工数を入力できるけど、
日々の合計値や一覧がないので少し使いにくい。

なので簡単に機能追加。
#かなり adhoc だけどローカル用だしね。

試したのは redmine-0.6.3。


(1) まずはコントローラを追加
ruby script/generate cotroller man_hour


(2) 各ファイルを追記したり作成したり修正したり。

--------------------------------------
app/controllers/man_hour_controller.rb
--------------------------------------
class ManHourController < ApplicationController
layout 'base'

def index
@time_entries = TimeEntry.find(:all,
:conditions => ['spent_on > ?',
Time.now - 14.day],
:order => 'user_id, issue_id, spent_on')

@time_entries = [] if !@time_entries

respond_to do |format|
format.html
end
end

end

-----------------------------
app/views/man_hour/index.html
-----------------------------
<h1>入力工数一覧</h1>

<% start_day = Time.now - 13.day -%>
<table class="list">
<tr>
<th>メンバ</th><th>課題</th>
<% 14.times do |n| -%>
<th>
<!-- %= (start_day + n.day).strftime("%m/%d") % -->
<% d = (start_day + n.day) -%>
<%= "#{d.month}/" if d.day == 1 %>
<%= d.day %>
</th>
<% end -%>
</tr>
<% max = @time_entries.length -%>
<% i = 0 -%>
<% while i < max -%>
<% entry = @time_entries[i] -%>
<tr class="<%=cycle('odd', 'even') %>">
<td><%= entry.user.name %></td>
<td>[<%= entry.project.name %>] <%= entry.issue.subject if entry.issue %></td>
<% issue_id = entry.issue_id -%>
<% 14.times do |n| -%>
<% if entry && (issue_id == entry.issue_id) && (entry.spent_on.day == (start_day + n.day).day) -%>
<td>
<!-- %= entry.hours % -->
<% if entry.user_id == User.current.id -%>
<%= link_to entry.hours, :controller => "timelog", :action => "edit", :id => entry.id %>
<% else -%>
<%= entry.hours %>
<% end -%>
</td>
<% i = i.next -%>
<% entry = @time_entries[i] -%>
<% else -%>
<td></td>
<% end -%>
<% end -%>
</tr>
<% end -%>
</table>

----------------
config/routes.rb
----------------
map.connect 'man_hour/', :controller => 'man_hour', :action => 'index' # 追記

--------------------------------
app/controllers/my_controller.rb
--------------------------------
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
'issuesreportedbyme' => :label_reported_issues,
'issueswatched' => :label_watched_issues,
'news' => :label_news_latest,
'calendar' => :label_calendar,
'documents' => :label_document_plural,
'hourhistories' => '入力工数履歴' # UTF8 で追記
}.freeze

----------------------------------------
app/views/my/blocks/_hourhistories.rhtml
----------------------------------------
<h3>入力工数履歴</h3>

<ul>
<% sql =
"select user_id, spent_on, sum(hours) as day_hour" +
" from time_entries" +
" where user_id = #{user.id}" +
" group by spent_on" +
" order by spent_on desc" +
" limit 5"-%>
<% for entry in TimeEntry.find_by_sql(sql) %>
<li><%= "#{entry.spent_on}: #{entry.day_hour} h" %>
<% end %>
</ul>

<%= link_to "詳細", :controller => "man_hour" %>