cds-snc / covid-alert-server

Exposure Notification: Diagnosis Server implementation / Notification d’exposition : Mise en œuvre du serveur de diagnostic
Apache License 2.0
298 stars 31 forks source link

feat: Add TEK Upload count table and data source #334

Closed maxneuvians closed 3 years ago

maxneuvians commented 3 years ago

Closes #333.

The PR adds an INSERT query that logs the amount of keys uploaded by a user in a database table called tek_upload_count. It saves this along with the current date and the originator. It also does a comparison to config.AppConstants.InitialRemainingKeys to see if this was the first time the user uploaded keys.

Additionally it exposes a new event endpoint events/uploads/YYYY-MM-DD that returns the raw data from the that table in JSON format for a specific date. The resulting data looks like this:

[
   {
      "source":"Province",
      "date":"2020-10-28",
      "count":14,
      "first_upload":true
   },
   {
      "source":"Province",
      "date":"2020-10-28",
      "count":1,
      "first_upload":false
   }
]

Lastly, it also add another event type OTKExpiredNoUploads which is a subset of OTKExpired. This metric shows all OTKs that were claimed but no keys were ever uploaded. This is determined if config.AppConstants.InitialRemainingKeys == remaining_keys. This data will be served through the already existing events\YYYY-MM-DD endpoint.

Screen Shot 2020-10-29 at 9 56 59 AM