Refactor the list measurements function to make use of nested queries (#662)

* Refactor the list measurements function to make use of nested queries

With a dataset of 1489 test, the ooniprobe list command went from
taking 17.27s to run, to requiring 0.17s or a 100x speed boost

See https://github.com/ooni/probe/issues/1966

* Remove dead code from actions

* Improve the tests for the ListResults function

* Add test for AnomalyCount

* Add more documentation about the merging of the test_keys
This commit is contained in:
Arturo Filastò 2022-01-14 11:24:43 +01:00 committed by GitHub
commit a884481b12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 80 deletions

View file

@ -11,8 +11,11 @@ import (
// ResultNetwork is used to represent the structure made from the JOIN
// between the results and networks tables.
type ResultNetwork struct {
Result `db:",inline"`
Network `db:",inline"`
Result `db:",inline"`
Network `db:",inline"`
AnomalyCount uint64 `db:"anomaly_count"`
TotalCount uint64 `db:"total_count"`
TestKeys string `db:"test_keys"`
}
// UploadedTotalCount is the count of the measurements which have been uploaded vs the total measurements in a given result set