ecm_time_tracking 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/ecm/time_tracking/sums_service.rb +35 -0
- data/lib/ecm/time_tracking/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6857aa59f1a8dd4a59651245ade35fa905352206
|
4
|
+
data.tar.gz: 4363edbf98c7caecfde1249fada18c0415f08d07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 662cd5dd51840573991047e3d36b80d68c23e4b8066523188831a899e0250d27bbc4eb8bb623f67861a3a4b257c61250639449d44191e3795d2e0326569840bc
|
7
|
+
data.tar.gz: 1bea1bad7143fd61219d1b57ed814c316bd95d1f38457e41f5908bf9bdaae9f52cdbecdf6fe2c96b8faabd1ae04abee3b7b6fbb77670fed7945c8cb4c6325d8c
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Ecm
|
2
|
+
module TimeTracking
|
3
|
+
class SumsService < Itsf::Services::V2::Service::Base
|
4
|
+
class Response < Itsf::Services::V2::Response::Base
|
5
|
+
attr_accessor :overtime, :count_by_entry_type
|
6
|
+
|
7
|
+
def overtime_in_hours
|
8
|
+
overtime / 3600
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :entries, :overtime, :count_by_entry_type
|
13
|
+
|
14
|
+
validates :entries, presence: true
|
15
|
+
|
16
|
+
def do_work
|
17
|
+
return response unless valid?
|
18
|
+
calculate_sums
|
19
|
+
response.overtime = overtime
|
20
|
+
response.count_by_entry_type = count_by_entry_type
|
21
|
+
response
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def calculate_sums
|
27
|
+
@overtime = entries.map(&:overtime).reduce(0, :+)
|
28
|
+
@count_by_entry_type = @entries.inject(Hash.new(0)) do |memo, entry|
|
29
|
+
memo[entry.entry_type] += 1
|
30
|
+
memo
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecm_time_tracking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- app/helpers/ecm/time_tracking/application_helper.rb
|
41
41
|
- app/models/ecm/time_tracking/entry.rb
|
42
42
|
- app/models/ecm/time_tracking/entry_type.rb
|
43
|
+
- app/services/ecm/time_tracking/sums_service.rb
|
43
44
|
- app/views/layouts/ecm/time_tracking/application.html.erb
|
44
45
|
- config/locales/de.yml
|
45
46
|
- config/routes.rb
|