0001-do-not-use-count-to-compute-emptyness-of-formdef-503.patch
tests/test_wcs.py | ||
---|---|---|
18 | 18 |
import json |
19 | 19 |
import pytest |
20 | 20 |
import pathlib |
21 |
from urllib.parse import urlparse, parse_qs |
|
21 | 22 | |
22 | 23 |
import unittest.mock as mock |
23 | 24 | |
... | ... | |
52 | 53 |
if 'limit' in call_args[0][0]] |
53 | 54 |
assert url_with_limits, call_args_list |
54 | 55 |
for url_with_limit in url_with_limits: |
55 |
assert 'limit=500&' in url_with_limit |
|
56 |
parsed_qs = parse_qs(urlparse(url_with_limit).query) |
|
57 |
assert parsed_qs.get('limit') |
|
58 |
assert int(parsed_qs['limit'][0]) <= 500 |
|
56 | 59 | |
57 | 60 |
assert ( |
58 | 61 |
'Le champ « 7th field bad duplicate » a un nom de variable dupliqué ' |
wcs_olap/feeder.py | ||
---|---|---|
491 | 491 |
self.create_referenced_table(table_name, formdef_fields, 'types de formulaire') |
492 | 492 | |
493 | 493 |
formdefs = [(form.slug, categories_mapping.get(form.schema.category), |
494 |
form.schema.name) for form in self.formdefs if form.count]
|
|
494 |
form.schema.name) for form in self.formdefs if not form.is_empty]
|
|
495 | 495 |
self.formdefs_mapping = self.do_referenced_data(table_name, formdefs, 'ref') |
496 | 496 |
self.update_table_sequence_number(table_name) |
497 | 497 | |
... | ... | |
564 | 564 |
self.do_dates_table() |
565 | 565 |
self.do_base_table() |
566 | 566 |
for formdef in self.formdefs: |
567 |
if not formdef.count:
|
|
567 |
if formdef.is_empty:
|
|
568 | 568 |
continue |
569 | 569 |
self.api.cache = {} |
570 | 570 |
try: |
wcs_olap/wcs_api.py | ||
---|---|---|
458 | 458 |
def formdatas(self): |
459 | 459 |
return FormDatas(wcs_api=self._wcs_api, formdef=self) |
460 | 460 | |
461 |
@property |
|
462 |
def is_empty(self): |
|
463 |
# self.count cannot be used as it's not the count of formdatas but a |
|
464 |
# weighted sum of the count on the last 30 days. |
|
465 |
return not bool(len(list(self.formdatas.anonymized[0:1]))) |
|
466 | ||
461 | 467 |
@property |
462 | 468 |
def schema(self): |
463 | 469 |
if not hasattr(self, '_schema'): |
464 |
- |