It still falls back to notification history if last_used_timestamp is None in the api_keys table
The function for last_used_timestamp doesn't account for "None" if the key has never been used.
Proposal Options:
Make an async celery job that will update the api keys the minute a user logs in. This will give us enough time to populate the last_used_timestamp if it is empty
Write a query that finds all the last_used_timestamp for each key - run this offine in a transaction in hasura - and it will update the api_keys_table
Personally I think we should do (2) as it solves for the None timestamp issue
The #2 suggestion does seems like the easiest and more bullet proof considering it would be best to populate all missing records and this is a one time operation.
Description
Previously we built this: https://app.zenhub.com/workspaces/notify-planning-614b3ad91bc2030015ed22f5/issues/gh/cds-snc/notification-planning/1413 to try and improve the performance of the API key page. This was unfortunately not good enough as:
Proposal Options:
Personally I think we should do (2) as it solves for the None timestamp issue
Once the above is done, change this function: https://github.com/cds-snc/notification-api/blob/main/app/dao/fact_notification_status_dao.py#L359-L372 to not use the notification and notification_history table.
QA Steps