You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1KB

  1. #!/usr/bin/env ruby
  2. require 'amazing_print'
  3. require 'date'
  4. require 'zlib'
  5. require 'oj'
  6. require_relative 'config.rb'
  7. reports = ARCDPS_BOSSES.fetch(:raids).collect do |boss|
  8. Dir["html/*_#{boss}_*.json.gz"].collect do |file|
  9. name = File.basename file
  10. date, boss, *_ = name.split '_'
  11. date = date.sub '-', ''
  12. date = DateTime.parse date
  13. [file, date, boss]
  14. end.group_by { |_, date, boss| [date.to_date, boss] }
  15. .to_h
  16. .transform_values { |v| v.sort { |a, b| a[1] <=> b[1] }.first }
  17. .collect { |_, v| v.first }
  18. end.flatten(1)
  19. count = reports.count
  20. puts "#{count} reports"
  21. reports = reports.collect do |file|
  22. json = File.open file do |fid|
  23. json = Zlib::GzipReader.new fid
  24. Oj.load json.read
  25. end
  26. json.fetch('players').collect { |p| p.fetch('profession') }
  27. end.flatten(1)
  28. count = reports.count
  29. reports = reports.inject(Hash.new 0) { |h, e| h[e] += 1; h }
  30. .sort { |a, b| b.last <=> a.last }
  31. .to_h
  32. .transform_values { |c| "#{c} (#{(c.to_f/count*100).round(2)}%)" }
  33. ap reports