mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Added delete time entry feature spec
This commit is contained in:
@@ -22,6 +22,6 @@ class TimeEntry < ActsAsLoggable::Log
|
||||
end
|
||||
|
||||
def type
|
||||
log_action.action
|
||||
log_action.try(:action)
|
||||
end
|
||||
end
|
||||
|
||||
+7
-8
@@ -65,15 +65,14 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def total_credits_spent
|
||||
log_action = ::ActsAsLoggable::TransactionAction.find_by_action("TIME")
|
||||
log_action_id = 1 #TIME
|
||||
transaction_logs.
|
||||
where( "log_action_id = ? AND log_action_type = ?",
|
||||
log_action.id, log_action.class.to_s).
|
||||
log_action_id, ::ActsAsLoggable::TransactionAction.to_s).
|
||||
sum{ |r| r.description.to_i }.round(2)
|
||||
end
|
||||
|
||||
def total_earned_credits
|
||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||
volunteer_id = 1
|
||||
staff_id = 3
|
||||
|
||||
@@ -98,20 +97,20 @@ class User < ActiveRecord::Base
|
||||
ORDER BY logs.created_at, conversion.created_at DESC",
|
||||
{id: self.id,
|
||||
credit_actions: [volunteer_id, staff_id],
|
||||
log_action_type: log_action.class.to_s}]).
|
||||
log_action_type: ::ActsAsLoggable::UserAction.to_s}]).
|
||||
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
||||
end
|
||||
|
||||
def total_hours
|
||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
||||
log_action_id = 4 #CHECKIN
|
||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
||||
end
|
||||
|
||||
def current_month_hours
|
||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||
log_action_id = 4 #CHECKIN
|
||||
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
||||
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
|
||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s)
|
||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s)
|
||||
.where( :start_date => current_month_range)
|
||||
.where( :end_date => current_month_range)
|
||||
.sum { |l| (l.end_date - l.start_date)/3600 }
|
||||
|
||||
Reference in New Issue
Block a user