refactor(server): modify log handler to reduce db calls #842
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is an improvement while retrieving job results. This morning I noticed the job detail view was loading a bit slow while getting the Phase Results (this was temporary, no issues as of now), I suspect it might be related to the fact that the the log reconstruction was making several database calls per phase and log_type.
This PR simplifies retrieving all log data associated to a job by making a single db request if either log_type or phase are not specified
Also included some typehints and docstrings that were missing from initial Logging Redesign PR
Resolved issues
NA
Documentation
Web service API changes
Tests
All existing tests are passing as this didn't modify the behavior of retrieving the logs.
Tested on staging
Results are retrievable via CLI with:
testflinger-cli --server https://testflinger-staging.canonical.com results c0b67076-4ecf-45f6-84a3-0046d5df8e93Results available in the UI:
https://testflinger-staging.canonical.com/jobs/c0b67076-4ecf-45f6-84a3-0046d5df8e93#phase-results