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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b936ab478caa99a6260d211b6fc4c1528a330dd3
4
- data.tar.gz: 15e4cdc015eff4ad33409115f04c1b32f3a0fd72
3
+ metadata.gz: 6857aa59f1a8dd4a59651245ade35fa905352206
4
+ data.tar.gz: 4363edbf98c7caecfde1249fada18c0415f08d07
5
5
  SHA512:
6
- metadata.gz: 09e4e82b3913bd5bc609640de5aa218fdb5dde2f1c44cf607cd20f29048d46be9729d474fff5c272f697012f4eb1fb8a9d8800a90e928659213ebae1c5b63bdc
7
- data.tar.gz: 3e7de5166bd9403912fb5a689c86a0bbdaf6b28cc072178f6aa99047eab0ed734cb9554b4b3398b291eecd1d98b0d3be1e06769962f882e501055d78c2c65acf
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
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module TimeTracking
3
- VERSION = '0.0.3'.freeze
3
+ VERSION = '0.0.4'.freeze
4
4
  end
5
5
  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.3
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-07 00:00:00.000000000 Z
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