slack-smart-bot 1.12.1 → 1.12.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc9fd817bfe7cb103d2f7e36ff695f6fc3784773ad6ad6f2b09b3a23dc5ac9a5
4
- data.tar.gz: 17a672f5844a78dd8542690bb84fc154d85f9aaca9e9cb4e1973f64abcc1a1f8
3
+ metadata.gz: ad123f03be6f0089506c0922817758ea95c049408fb0fcaf0a32b60a813d3c69
4
+ data.tar.gz: 830795a923d755e6b3d92b6a3edf328438f68e855fe3eaaa6ee3a59a43351b3c
5
5
  SHA512:
6
- metadata.gz: 501f2eeeae3ab81dc44bb468010aa08080f26adee77b3092e4f16e5a17f4d10ab611962279d7da2b0b8ecd92870cfd586206e61e232b5fa38f317221a94fbdd1
7
- data.tar.gz: 5ed19d0cb973d1e21ab8cc9b8646153ce0c821ed47850a50d1cfe16bd26dbbfd6903253bdb50780e3d7ab01d5f943739369d536b849f21e46d991c3ea48567bd
6
+ metadata.gz: 37a4da4e6d66617fe11095d932b4cdc34ef6df6cfa1e15aac45b46d28867f69226cd07908d682fee8d4dd5b6133fa57f701d14b591cec911250956592f14124c
7
+ data.tar.gz: 6481d7e7e66d4877454d44112e72fb5e41c041951f2627fc5b021631340e85efce4871d7c82304cb4968b063721bcd1b32a41c085070451afd24c583e7618cb6
@@ -75,6 +75,7 @@ class SlackSmartBot
75
75
  end
76
76
  end
77
77
  tzone_users = {}
78
+ job_title_users = {}
78
79
 
79
80
  unless wrong
80
81
  if on_dm_master or (from_user.id == user) # normal user can only see own stats
@@ -318,6 +319,30 @@ class SlackSmartBot
318
319
  end
319
320
  end
320
321
  end
322
+ if rows[0].key?(:job_title) #then save_stats is saving the job title already
323
+ rows.job_title.each do |job_title|
324
+ unless job_title == ''
325
+ job_title_users[job_title] ||= 0
326
+ job_title_users[job_title] += 1
327
+ end
328
+ end
329
+ else
330
+ rows.user_id.each_with_index do |usr, i|
331
+ if rows[i].values.size >= 13 #then save_stats is saving the job_title already but not all the data
332
+ unless rows[i].values[12] == ''
333
+ job_title_users[rows[i].values[12]] ||= 0
334
+ job_title_users[rows[i].values[12]] += 1
335
+ end
336
+ else
337
+ user_info = @users.select { |u| u.id == usr or (u.key?(:enterprise_user) and u.enterprise_user.id == usr) }[-1]
338
+ unless user_info.nil? or user_info.is_app_user or user_info.is_bot
339
+ job_title_users[user_info.profile.title] ||= 0
340
+ job_title_users[user_info.profile.title] += 1
341
+ end
342
+ end
343
+ end
344
+ end
345
+
321
346
  if users.size > 10
322
347
  message << "*Users* - #{users.size} (Top 10)"
323
348
  else
@@ -356,6 +381,25 @@ class SlackSmartBot
356
381
  total_unknown = total_without_routines - total_known
357
382
  message << "\tUnknown: #{total_unknown} (#{(total_unknown.to_f*100/total_without_routines).round(2)}%)" if total_unknown > 0
358
383
  end
384
+
385
+ if job_title_users.size > 0
386
+ if job_title_users.size > 10
387
+ message << "*Job Titles* - #{job_title_users.size} (Top 10)"
388
+ else
389
+ message << "*Job Titles* - #{job_title_users.size}"
390
+ end
391
+ total_known = 0
392
+ i = 0
393
+ job_title_users.sort_by {|k,v| -v}.each do |jtitle, num|
394
+ i += 1
395
+ if i <= 10
396
+ message << "\t#{jtitle}: #{num} (#{(num.to_f*100/total_without_routines).round(2)}%)"
397
+ end
398
+ total_known+=num
399
+ end
400
+ total_unknown = total_without_routines - total_known
401
+ message << "\tUnknown: #{total_unknown} (#{(total_unknown.to_f*100/total_without_routines).round(2)}%)" if total_unknown > 0
402
+ end
359
403
 
360
404
  end
361
405
  commands_attachment = []
@@ -6,7 +6,7 @@ class SlackSmartBot
6
6
  require "csv"
7
7
  if !File.exist?("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log")
8
8
  CSV.open("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log", "wb") do |csv|
9
- csv << ["date", "bot_channel", "bot_channel_id", "dest_channel", "dest_channel_id", "type_message", "user_name", "user_id", "text", "command", "files", "time_zone"]
9
+ csv << ["date", "bot_channel", "bot_channel_id", "dest_channel", "dest_channel_id", "type_message", "user_name", "user_id", "text", "command", "files", "time_zone", "job_title"]
10
10
  end
11
11
  end
12
12
  if data.empty?
@@ -37,12 +37,14 @@ class SlackSmartBot
37
37
  user_info = @users.select { |u| u.id == user_id or (u.key?(:enterprise_user) and u.enterprise_user.id == user_id) }[-1]
38
38
  if user_info.nil? or user_info.is_app_user or user_info.is_bot
39
39
  time_zone = ''
40
+ job_title = ''
40
41
  else
41
42
  time_zone = user_info.tz_label
43
+ job_title = user_info.profile.title
42
44
  end
43
45
 
44
46
  CSV.open("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log", "a+") do |csv|
45
- csv << [Time.now, config.channel, @channel_id, @channels_name[data.dest], data.dest, data.typem, user_name, user_id, command_txt, method, data.files, time_zone]
47
+ csv << [Time.now, config.channel, @channel_id, @channels_name[data.dest], data.dest, data.typem, user_name, user_id, command_txt, method, data.files, time_zone, job_title]
46
48
  end
47
49
  rescue Exception => exception
48
50
  @logger.fatal "There was a problem on the stats"
data/whats_new.txt CHANGED
@@ -1,4 +1,4 @@
1
- *Version 1.12.1* Released 2022-Oct-06
1
+ *Version 1.12.3* Released 2022-Nov-01
2
2
 
3
3
  *For General users*
4
4
  - `run repl` accepts local parameters and precode to be supplied (<https://github.com/MarioRuiz/slack-smart-bot/issues/60|#60>).
@@ -13,6 +13,7 @@
13
13
  *For Admin users*
14
14
  - Bot Stats is now saving the time_zone of the user (<https://github.com/MarioRuiz/slack-smart-bot/issues/66|#66>)
15
15
  - Announcements won't be published if no activity on channel. (<https://github.com/MarioRuiz/slack-smart-bot/issues/74|#74>)
16
+ - Bot Stats is now saving the job title of the user (<https://github.com/MarioRuiz/slack-smart-bot/issues/77|#77>)
16
17
  ------------------------------
17
18
 
18
19
  *Previous*: <https://github.com/MarioRuiz/slack-smart-bot/blob/b1a368c3342094e886f53d96dc4d12ecd81ab04b/whats_new.txt|1.11.0>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-smart-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client