[refs #223] some refactoring
This commit is contained in:
parent
89756ded0c
commit
42967381b6
|
@ -66,22 +66,16 @@ class BuildList < ActiveRecord::Base
|
|||
scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) }
|
||||
scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) }
|
||||
scope :for_creation_date_period, lambda{|start_date, end_date|
|
||||
if start_date && end_date
|
||||
where(["#{table_name}.created_at BETWEEN ? AND ?", start_date, end_date])
|
||||
elsif start_date && !end_date
|
||||
where(["#{table_name}.created_at >= ?", start_date])
|
||||
elsif !start_date && end_date
|
||||
where(["#{table_name}.created_at <= ?", end_date])
|
||||
end
|
||||
scoped = BuildList.scoped
|
||||
scoped = scoped.where(["created_at >= ?", start_date]) if start_date
|
||||
scoped = scoped.where(["created_at <= ?", end_date]) if end_date
|
||||
scoped
|
||||
}
|
||||
scope :for_notified_date_period, lambda{|start_date, end_date|
|
||||
if start_date && end_date
|
||||
where(["updated_at BETWEEN ? AND ?", start_date, end_date])
|
||||
elsif start_date && !end_date
|
||||
where(["updated_at >= ?", start_date])
|
||||
elsif !start_date && end_date
|
||||
where(["updated_at <= ?", end_date])
|
||||
end
|
||||
scoped = BuildList.scoped
|
||||
scoped = scoped.where(["updated_at >= ?", start_date]) if start_date
|
||||
scoped = scoped.where(["updated_at <= ?", end_date]) if end_date
|
||||
scoped
|
||||
}
|
||||
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
||||
|
||||
|
|
|
@ -22,26 +22,11 @@
|
|||
%h3= t("layout.activity_feed.my_builds_by_day")
|
||||
%table{:cellpadding => "0", :cellspacing => "0"}
|
||||
%tbody
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{:build_published}"), build_lists_path(:filter => {:status => BuildList::BUILD_PUBLISHED, :updated_at => midnight})
|
||||
%td= BuildList.for_status(BuildList::BUILD_PUBLISHED).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{:success}"), build_lists_path(:filter => {:status => BuildServer::SUCCESS, :updated_at => midnight})
|
||||
%td= BuildList.for_status(BuildServer::SUCCESS).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{:build_started}"), build_lists_path(:filter => {:status => BuildServer::BUILD_STARTED, :updated_at => midnight})
|
||||
%td= BuildList.for_status(BuildServer::BUILD_STARTED).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{:build_pending}"), build_lists_path(:filter => {:status => BuildList::BUILD_PENDING, :updated_at => midnight})
|
||||
%td= BuildList.for_status(BuildList::BUILD_PENDING).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{:build_error}"), build_lists_path(:filter => {:status => BuildServer::BUILD_ERROR, :updated_at => midnight})
|
||||
%td= BuildList.for_status(BuildServer::BUILD_ERROR).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
- ['BuildList::BUILD_PUBLISHED', 'BuildServer::SUCCESS', 'BuildServer::BUILD_STARTED', 'BuildList::BUILD_PENDING', 'BuildServer::BUILD_ERROR'].each do |state|
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.build_lists.statuses.#{state.demodulize.downcase}"), build_lists_path(:filter => {:status => state.constantize, :updated_at => midnight})
|
||||
%td= BuildList.for_status(state.constantize).for_user(current_user).for_notified_date_period(midnight, nil).count
|
||||
%tr
|
||||
%td.first
|
||||
= link_to t("layout.activity_feed.all_my_builds"), build_lists_path
|
||||
|
|
Loading…
Reference in New Issue