udata 10.8.3.dev37212__py2.py3-none-any.whl → 10.8.3.dev37263__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/organization/csv.py +9 -26
- udata/tests/organization/test_csv_adapter.py +3 -15
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/METADATA +2 -1
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/RECORD +8 -8
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/LICENSE +0 -0
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/WHEEL +0 -0
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/entry_points.txt +0 -0
- {udata-10.8.3.dev37212.dist-info → udata-10.8.3.dev37263.dist-info}/top_level.txt +0 -0
udata/core/organization/csv.py
CHANGED
|
@@ -4,6 +4,13 @@ from udata.core.dataset.models import Dataset
|
|
|
4
4
|
from .models import Organization
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
def get_resource_download_count(organization: Organization) -> int:
|
|
8
|
+
return sum(
|
|
9
|
+
dat.metrics.get("resources_downloads", 0) or 0
|
|
10
|
+
for dat in Dataset.objects(organization=organization).only("metrics").visible()
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
7
14
|
@csv.adapter(Organization)
|
|
8
15
|
class OrganizationCsvAdapter(csv.Adapter):
|
|
9
16
|
downloads_counts = None
|
|
@@ -21,32 +28,8 @@ class OrganizationCsvAdapter(csv.Adapter):
|
|
|
21
28
|
"last_modified",
|
|
22
29
|
"business_number_id",
|
|
23
30
|
("members_count", lambda o: len(o.members)),
|
|
31
|
+
("downloads", get_resource_download_count),
|
|
24
32
|
)
|
|
25
33
|
|
|
26
34
|
def dynamic_fields(self):
|
|
27
|
-
return csv.metric_fields(Organization)
|
|
28
|
-
|
|
29
|
-
def get_dynamic_field_downloads(self):
|
|
30
|
-
downloads_counts = self.get_downloads_counts()
|
|
31
|
-
return [("downloads", lambda o: downloads_counts.get(str(o.id), 0))]
|
|
32
|
-
|
|
33
|
-
def get_downloads_counts(self):
|
|
34
|
-
"""
|
|
35
|
-
Prefetch all the resources' downloads for all selected organization into memory
|
|
36
|
-
"""
|
|
37
|
-
if self.downloads_counts is not None:
|
|
38
|
-
return self.downloads_counts
|
|
39
|
-
|
|
40
|
-
self.downloads_counts = {}
|
|
41
|
-
|
|
42
|
-
ids = [o.id for o in self.queryset]
|
|
43
|
-
for dataset in Dataset.objects(organization__in=ids):
|
|
44
|
-
org_id = str(dataset.organization.id)
|
|
45
|
-
if self.downloads_counts.get(org_id) is None:
|
|
46
|
-
self.downloads_counts[org_id] = 0
|
|
47
|
-
|
|
48
|
-
self.downloads_counts[org_id] += sum(
|
|
49
|
-
resource.metrics.get("views", 0) for resource in dataset.resources
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
return self.downloads_counts
|
|
35
|
+
return csv.metric_fields(Organization)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
|
-
from udata.core.dataset.factories import DatasetFactory
|
|
3
|
+
from udata.core.dataset.factories import DatasetFactory
|
|
4
4
|
from udata.core.organization.csv import OrganizationCsvAdapter
|
|
5
5
|
from udata.core.organization.factories import OrganizationFactory
|
|
6
6
|
from udata.core.organization.models import Organization
|
|
@@ -15,21 +15,9 @@ class OrganizationCSVAdapterTest:
|
|
|
15
15
|
|
|
16
16
|
DatasetFactory(
|
|
17
17
|
organization=org_with_dataset,
|
|
18
|
-
|
|
19
|
-
ResourceFactory(
|
|
20
|
-
metrics={
|
|
21
|
-
"views": 42,
|
|
22
|
-
}
|
|
23
|
-
),
|
|
24
|
-
ResourceFactory(
|
|
25
|
-
metrics={
|
|
26
|
-
"views": 1337,
|
|
27
|
-
}
|
|
28
|
-
),
|
|
29
|
-
ResourceFactory(),
|
|
30
|
-
],
|
|
18
|
+
metrics={"resources_downloads": 1337},
|
|
31
19
|
)
|
|
32
|
-
DatasetFactory(organization=org_with_dataset,
|
|
20
|
+
DatasetFactory(organization=org_with_dataset, metrics={"resources_downloads": 42})
|
|
33
21
|
adapter = OrganizationCsvAdapter(Organization.objects.all())
|
|
34
22
|
|
|
35
23
|
# Build a dict (Org ID to dict of header name to value) from the CSV values and headers to simplify testing below.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 10.8.3.
|
|
3
|
+
Version: 10.8.3.dev37263
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -151,6 +151,7 @@ It is collectively taken care of by members of the
|
|
|
151
151
|
- Cache dcat harvest pages to avoid two rounds of requests [#3398](https://github.com/opendatateam/udata/pull/3398)
|
|
152
152
|
- Ignore Dataset.accessService when processing DataService [#3399](https://github.com/opendatateam/udata/pull/3399)
|
|
153
153
|
- Add dataset field `description_short` [#3397](https://github.com/opendatateam/udata/pull/3397)
|
|
154
|
+
- Optimize csv organization export [#3401](https://github.com/opendatateam/udata/pull/3401)
|
|
154
155
|
|
|
155
156
|
## 10.8.2 (2025-07-31)
|
|
156
157
|
|
|
@@ -154,7 +154,7 @@ udata/core/organization/api_fields.py,sha256=UlDYS62Wt1capSO0rYf6-m_rza3lCmpTuA9
|
|
|
154
154
|
udata/core/organization/apiv2.py,sha256=fLMN5T7s8yF4u7c1WWHXMqQAlyH2OCSyAfmleiFlf7M,3037
|
|
155
155
|
udata/core/organization/commands.py,sha256=DsRAtFDZvTciYNsUWumQWdn0jnNmKW-PwfIHUUZoBb8,1591
|
|
156
156
|
udata/core/organization/constants.py,sha256=fncNtA-vFrRM22K1Wo6iYu9DQZjzknYxH6TIYfxM9kA,563
|
|
157
|
-
udata/core/organization/csv.py,sha256=
|
|
157
|
+
udata/core/organization/csv.py,sha256=zdLeB4La-TeOEELg0WI3FryoQWnoAYit_DssInVSHRI,979
|
|
158
158
|
udata/core/organization/factories.py,sha256=g8ubBcz79xbjvpunZ02IDOakFg1KE6cXjNkE9vFyFAc,624
|
|
159
159
|
udata/core/organization/forms.py,sha256=tscDb1_yOpbTx3ahl8ttA7oDkX9jIyzLc4gOf6WbN3s,3552
|
|
160
160
|
udata/core/organization/metrics.py,sha256=CEhkZLUufDyWi2XyizMoXkuddz7xDJvmdkPTweqfWyI,1144
|
|
@@ -717,7 +717,7 @@ udata/tests/metrics/helpers.py,sha256=1l5SvbWkWkXiJHmAAbf7VzSGhJY9eJxTtJ2S4cVB8T
|
|
|
717
717
|
udata/tests/metrics/test_metrics.py,sha256=DHdHPdrTHPEIIRW0gwvYqQALfWkrPk4R4rjcT6C6mJM,2619
|
|
718
718
|
udata/tests/metrics/test_tasks.py,sha256=asTCdErabrPQClFu-36HDVzqd8ZfQjsAJ4kULhpxdio,5589
|
|
719
719
|
udata/tests/organization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
720
|
-
udata/tests/organization/test_csv_adapter.py,sha256=
|
|
720
|
+
udata/tests/organization/test_csv_adapter.py,sha256=61XIVDYdZxnWUyysN_wApWwghM7nT_Id-74IMtFd3Zg,1263
|
|
721
721
|
udata/tests/organization/test_notifications.py,sha256=PGmME5BbYVtcPffeSE1sx47J6iAfm4RDAZIRv_MXDFE,1366
|
|
722
722
|
udata/tests/organization/test_organization_model.py,sha256=ZEUHX7lvGMYMlHDpPiVUPeZeJeDDTp5owLEpFDSihjc,4311
|
|
723
723
|
udata/tests/organization/test_organization_rdf.py,sha256=Uf-OgXV615wLUHfcBTmp9QFuV8VCFmjI4wgvShve-mc,8074
|
|
@@ -758,9 +758,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=ogtEGsjwIkOEtzrI49e57izi-NUim5
|
|
|
758
758
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=1omSlqdMEdwYtzHGalXrtptVk14mlb6JS_8xR8BsznU,48428
|
|
759
759
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=V7unDjO31PNLiRhfEkYU3pU47wWWct-otdL0GDma0S4,28692
|
|
760
760
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=wVBipfpPl-DmYeVm5wrlzWWM3oEvuruDVbJHx4I1p8s,55170
|
|
761
|
-
udata-10.8.3.
|
|
762
|
-
udata-10.8.3.
|
|
763
|
-
udata-10.8.3.
|
|
764
|
-
udata-10.8.3.
|
|
765
|
-
udata-10.8.3.
|
|
766
|
-
udata-10.8.3.
|
|
761
|
+
udata-10.8.3.dev37263.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
762
|
+
udata-10.8.3.dev37263.dist-info/METADATA,sha256=ggikfx2gSGCDLw950R_xyJiFj-7oRLUgv7KvT0L-MNI,154041
|
|
763
|
+
udata-10.8.3.dev37263.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
|
|
764
|
+
udata-10.8.3.dev37263.dist-info/entry_points.txt,sha256=v2u12qO11i2lyLNIp136WmLJ-NHT-Kew3Duu8J-AXPM,614
|
|
765
|
+
udata-10.8.3.dev37263.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
766
|
+
udata-10.8.3.dev37263.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|