pampa_workers 1.1.1 → 1.1.6
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/mybotprocess.rb +35 -1
- data/lib/worker.rb +14 -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: ea7a798bc3f03abdb8eb364bc07244f71a9fca3a
|
4
|
+
data.tar.gz: 48785340917afd5e32d8156b42f7c6d2bcbcd612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a4ae4c26674afb0e6d6ddc2f2f1c6622a4ef3e30fcef8c705f4297ed722e8b0186c30986a5c8f3e632159df99fa830f4e3fc9e23e8aadd164d6c44b9605292
|
7
|
+
data.tar.gz: a1cd15fb0e37875cef2969d8bad8ff21d5b0ce2d5f0197cd4cc6b4deb0e17543f579f33a1068c367cdf5860d19612f9bb30f8f0e3ae3843dafbcd06c85b936ed
|
data/lib/mybotprocess.rb
CHANGED
@@ -101,7 +101,39 @@ module BlackStack
|
|
101
101
|
|
102
102
|
return lnuser
|
103
103
|
end # getLnUser()
|
104
|
+
|
105
|
+
#
|
106
|
+
def notifyInbox(lnuser, conv)
|
107
|
+
conv[:chats].each { |chat|
|
108
|
+
# armo URL de notificacion
|
109
|
+
# se usa URI.encode para codificar caracteres no-ascii en los mensajes
|
110
|
+
url =
|
111
|
+
"#{BlackStack::Pampa::api_protocol}://#{self.ws_url}:#{self.ws_port}/api1.3/pampa/scrape.inbox/notify_lnchat.json?" +
|
112
|
+
"api_key=#{BlackStack::Pampa::api_key}&" +
|
113
|
+
"profile_code=#{URI.escape(conv[:profile_code])}&" +
|
114
|
+
"profile_name=#{URI.escape(conv[:profile_name])}&" +
|
115
|
+
"profile_headline=#{URI.escape(conv[:profile_headline])}&" +
|
116
|
+
"first=#{URI.escape(conv[:first])}&" +
|
117
|
+
"position=#{chat[:position].to_s}&" +
|
118
|
+
"uid=#{lnuser['id']}&" +
|
119
|
+
"sender_name=#{URI.escape(chat[:sender_name])}&" +
|
120
|
+
"body=#{URI.escape(chat[:body])}&"
|
121
|
+
puts ""
|
122
|
+
puts "url:#{url}:."
|
123
|
+
puts ""
|
124
|
+
# HELP: File.open('./output3.txt', 'a') { |file| file.write(url + "\r\n") }
|
104
125
|
|
126
|
+
# push the chat
|
127
|
+
uri = URI.parse(url.to_s)
|
128
|
+
req = Net::HTTP::Get.new(uri.to_s)
|
129
|
+
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|
|
130
|
+
http.request(req)
|
131
|
+
}
|
132
|
+
parsed = JSON.parse(res.body)
|
133
|
+
raise "error uploading chat: #{parsed['status']}" if parsed['status'] != 'success'
|
134
|
+
} # conv[:chats].each
|
135
|
+
end
|
136
|
+
|
105
137
|
#
|
106
138
|
def notifyLnUserUrl(id_lnuser, profile_url)
|
107
139
|
nTries = 0
|
@@ -304,8 +336,9 @@ module BlackStack
|
|
304
336
|
return ret
|
305
337
|
end # isLnUserAvailable
|
306
338
|
|
307
|
-
#
|
339
|
+
# TODO: deprecated
|
308
340
|
def releaseLnUser(id_lnuser, workflow_name='incrawl.lnsearchvariation')
|
341
|
+
=begin
|
309
342
|
nTries = 0
|
310
343
|
parsed = nil
|
311
344
|
bSuccess = false
|
@@ -339,6 +372,7 @@ module BlackStack
|
|
339
372
|
end
|
340
373
|
|
341
374
|
return ret
|
375
|
+
=end
|
342
376
|
end # isLnUserAvailable
|
343
377
|
|
344
378
|
end # class MyBotProcess
|
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.
|
@@ -98,6 +109,7 @@ module BlackStack
|
|
98
109
|
w.id_client = h['id_client']
|
99
110
|
w.id_division = h['id_division']
|
100
111
|
w.division_name = h['division_name']
|
112
|
+
w.public_ip_address = h['public_ip_address']
|
101
113
|
w.save
|
102
114
|
end
|
103
115
|
|
@@ -112,6 +124,7 @@ module BlackStack
|
|
112
124
|
h['id_client'] = self.id_client
|
113
125
|
h['id_division'] = self.id_division
|
114
126
|
h['division_name'] = self.division_name
|
127
|
+
h['public_ip_address'] = self.public_ip_address
|
115
128
|
h
|
116
129
|
end
|
117
130
|
|
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.6
|
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-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|