do not use count to compute emptyness of formdef (#50368)
This commit is contained in:
parent
30f6873d27
commit
fe2f5b5d89
|
@ -18,6 +18,7 @@ import datetime
|
|||
import json
|
||||
import pytest
|
||||
import pathlib
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
import unittest.mock as mock
|
||||
|
||||
|
@ -52,7 +53,9 @@ def test_wcs_fixture(wcs, postgres_db, tmpdir, olap_cmd, caplog):
|
|||
if 'limit' in call_args[0][0]]
|
||||
assert url_with_limits, call_args_list
|
||||
for url_with_limit in url_with_limits:
|
||||
assert 'limit=500&' in url_with_limit
|
||||
parsed_qs = parse_qs(urlparse(url_with_limit).query)
|
||||
assert parsed_qs.get('limit')
|
||||
assert int(parsed_qs['limit'][0]) <= 500
|
||||
|
||||
assert (
|
||||
'Le champ « 7th field bad duplicate » a un nom de variable dupliqué '
|
||||
|
|
|
@ -491,7 +491,7 @@ class WcsOlapFeeder(object):
|
|||
self.create_referenced_table(table_name, formdef_fields, 'types de formulaire')
|
||||
|
||||
formdefs = [(form.slug, categories_mapping.get(form.schema.category),
|
||||
form.schema.name) for form in self.formdefs if form.count]
|
||||
form.schema.name) for form in self.formdefs if not form.is_empty]
|
||||
self.formdefs_mapping = self.do_referenced_data(table_name, formdefs, 'ref')
|
||||
self.update_table_sequence_number(table_name)
|
||||
|
||||
|
@ -564,7 +564,7 @@ class WcsOlapFeeder(object):
|
|||
self.do_dates_table()
|
||||
self.do_base_table()
|
||||
for formdef in self.formdefs:
|
||||
if not formdef.count:
|
||||
if formdef.is_empty:
|
||||
continue
|
||||
self.api.cache = {}
|
||||
try:
|
||||
|
|
|
@ -458,6 +458,12 @@ class FormDef(BaseObject):
|
|||
def formdatas(self):
|
||||
return FormDatas(wcs_api=self._wcs_api, formdef=self)
|
||||
|
||||
@property
|
||||
def is_empty(self):
|
||||
# self.count cannot be used as it's not the count of formdatas but a
|
||||
# weighted sum of the count on the last 30 days.
|
||||
return len(list(self.formdatas.anonymized[0:1])) == 0
|
||||
|
||||
@property
|
||||
def schema(self):
|
||||
if not hasattr(self, '_schema'):
|
||||
|
|
Loading…
Reference in New Issue