pampa_workers 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/worker.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 782e133cec2c858b619c751b3bf51df20e29f771
|
4
|
+
data.tar.gz: 42f4cab18236d5c33be917894ddad9195a6047b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ce7738ae0bcc792a35fdd132d081bf94fa2da36dbfff2b20d5d6093b17847675aa9ae567d810bcecd94e20550c5931238e7c937db0fa5b0977cfa55e35eab1
|
7
|
+
data.tar.gz: 3eec7d8fed322007313031574e103442fd7585200ad364c5f333f20579270630cbf63e0c66f14fe0a488de20f2b21145c78d46cf2c0f932e85e78402a204a7bf
|
data/lib/worker.rb
CHANGED
@@ -37,6 +37,15 @@ module BlackStack
|
|
37
37
|
# Note that the same worker may has been assigned to different clients withing the same timeframe.
|
38
38
|
# This method will compute the seconds used by this client only, over the total timeframe.
|
39
39
|
def self.client_usage_ratio(id_client, period='M', units=1)
|
40
|
+
#
|
41
|
+
row = DB[
|
42
|
+
"select count(*) as total_workers " +
|
43
|
+
"from worker w with (nolock) " +
|
44
|
+
"where w.id_client = '#{id_client}' "
|
45
|
+
].first
|
46
|
+
t = row[:total_workers].to_f
|
47
|
+
|
48
|
+
#
|
40
49
|
row = DB[
|
41
50
|
"select datediff(ss, dateadd(#{period}#{period}, -#{units.to_s}, getdate()), getdate()) as total_seconds, isnull(sum(datediff(ss, j.job_start_time, j.job_end_time)), 0) as used_seconds " +
|
42
51
|
"from workerjob j with (nolock) " +
|
@@ -45,9 +54,11 @@ module BlackStack
|
|
45
54
|
"and j.job_start_time is not null " +
|
46
55
|
"and j.job_end_time is not null "
|
47
56
|
].first
|
57
|
+
|
58
|
+
#
|
48
59
|
x = row[:used_seconds].to_f
|
49
60
|
y = row[:total_seconds].to_f
|
50
|
-
100.to_f * x / y
|
61
|
+
100.to_f * ( x / t ) / y
|
51
62
|
end
|
52
63
|
|
53
64
|
# Usage ratio this worker by this client.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pampa_workers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|