Skip to content

Commit a001b0a

Browse files
authored
fix(models.py): add missing experiments (#206)
0.14 Fix get_recent_test_coverage
1 parent 0c59db1 commit a001b0a

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

newapi/debian/changelog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ooni-api (0.14) unstable; urgency=medium
2+
3+
* Fix get_recent_test_coverage
4+
5+
-- Federico Ceratto <[email protected]> Fri, 04 Dec 2020 16:21:51 +0000
6+
17
ooni-api (0.13) unstable; urgency=medium
28

39
* add dnscheck, urlgetter experiment names

newapi/ooniapi/models.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
"tcp_connect",
1818
"psiphon",
1919
"tor",
20+
"riseupvpn",
2021
],
2122
"legacy": [
2223
"http_requests",
2324
"dns_consistency",
2425
"http_host",
2526
"multi_protocol_traceroute",
2627
],
28+
"experimental": [
29+
"urlgetter",
30+
"dnscheck",
31+
],
2732
}
2833

2934

newapi/ooniapi/private.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,13 @@ def get_recent_test_coverage(probe_cc):
299299
q = current_app.db_session.execute(s, {"probe_cc": probe_cc})
300300
coverage_map = {k: {} for k in TEST_GROUPS.keys()}
301301
for count, measurement_start_day, test_group in q:
302-
coverage_map[test_group][measurement_start_day.strftime("%Y-%m-%d")] = int(
303-
count
304-
)
302+
ts = measurement_start_day.strftime("%Y-%m-%d")
303+
count = int(count)
304+
try:
305+
coverage_map[test_group][ts] = count
306+
except KeyError as e:
307+
# test_group='unknown' for missing test name in TEST_GROUPS
308+
log.error(e, exc_info=1)
305309

306310
test_coverage = []
307311
for test_group, coverage in coverage_map.items():
@@ -492,11 +496,15 @@ def api_private_website_test_urls():
492496
# Create next_url
493497
if len(results) >= limit:
494498
args = dict(
495-
limit=limit, offset=offset + limit, probe_asn=probe_asn, probe_cc=probe_cc,
499+
limit=limit,
500+
offset=offset + limit,
501+
probe_asn=probe_asn,
502+
probe_cc=probe_cc,
496503
)
497504
# TODO: remove BASE_URL?
498505
next_url = urljoin(
499-
current_app.config["BASE_URL"], "/api/_/website_urls?%s" % urlencode(args),
506+
current_app.config["BASE_URL"],
507+
"/api/_/website_urls?%s" % urlencode(args),
500508
)
501509
metadata["next_url"] = next_url
502510

@@ -609,8 +617,7 @@ def api_private_im_networks():
609617

610618

611619
def isomid(d) -> str:
612-
"""Returns 2020-08-01T00:00:00+00:00
613-
"""
620+
"""Returns 2020-08-01T00:00:00+00:00"""
614621
return f"{d}T00:00:00+00:00"
615622

616623

0 commit comments

Comments
 (0)