Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Prototype for grade reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Claudius committed Jun 14, 2017
1 parent 293dc72 commit 491d52e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ssh_scan_api/api.rb
Expand Up @@ -195,7 +195,8 @@ class API < Sinatra::Base
"RUNNING" => settings.db.run_count,
"ERRORED" => settings.db.error_count,
"COMPLETED" => settings.db.complete_count,
"TOTAL" => settings.db.total_count
"TOTAL" => settings.db.total_count,
"GRADE_REPORT" => settings.db.grade_report
}.to_json
end

Expand Down
4 changes: 4 additions & 0 deletions lib/ssh_scan_api/database.rb
Expand Up @@ -53,6 +53,10 @@ def get_scan(uuid)
@database.get_scan(uuid)
end

def grade_report
@database.grade_report
end

def queue_scan(uuid, socket)
@database.queue_scan(uuid, socket)
end
Expand Down
11 changes: 11 additions & 0 deletions lib/ssh_scan_api/database/mongo.rb
Expand Up @@ -84,6 +84,17 @@ def error_scan(uuid, worker_id, result)
)
end

def grade_report
grades = ["A", "B", "C", "D", "F"]
histogram = {}

grades.each do |grade|
histogram[grade] = @collection.count("scan.compliance.grade": grade)
end

return histogram
end

def next_scan_in_queue()
@collection.find(status: "QUEUED").first
end
Expand Down

0 comments on commit 491d52e

Please sign in to comment.