udata 9.2.2.dev31819__py2.py3-none-any.whl → 9.2.3__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/__init__.py +1 -1
- udata/core/discussions/api.py +1 -1
- udata/migrations/2024-10-01-remove-ods-duplicates.py +97 -0
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/METADATA +7 -2
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/RECORD +9 -8
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/LICENSE +0 -0
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/WHEEL +0 -0
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/entry_points.txt +0 -0
- {udata-9.2.2.dev31819.dist-info → udata-9.2.3.dist-info}/top_level.txt +0 -0
udata/__init__.py
CHANGED
udata/core/discussions/api.py
CHANGED
|
@@ -77,7 +77,7 @@ comment_discussion_fields = api.model(
|
|
|
77
77
|
discussion_page_fields = api.model("DiscussionPage", fields.pager(discussion_fields))
|
|
78
78
|
|
|
79
79
|
parser = api.parser()
|
|
80
|
-
sorting_keys: list[str] = ["created", "title", "closed"]
|
|
80
|
+
sorting_keys: list[str] = ["created", "title", "closed", "discussion.posted_on"]
|
|
81
81
|
sorting_choices: list[str] = sorting_keys + ["-" + k for k in sorting_keys]
|
|
82
82
|
parser.add_argument(
|
|
83
83
|
"sort",
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Remove duplicate OpenDataSoft resources
|
|
3
|
+
The duplicate are due to ODS modifying the URL of their CSV and XLSX exports,
|
|
4
|
+
the URL being the identifier of the resources in DCAT harvesting.
|
|
5
|
+
The default /export/csv had been existing since harvesting ODS with DCAT.
|
|
6
|
+
2024-08-07 : `use_labels=false` appended at the end of the URL -> first duplicates
|
|
7
|
+
2024-08-09 : replaced by `use_labels=true` -> second set of duplicates
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import traceback
|
|
12
|
+
|
|
13
|
+
from mongoengine.errors import ValidationError
|
|
14
|
+
|
|
15
|
+
from udata.models import Dataset
|
|
16
|
+
|
|
17
|
+
log = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def migrate(db):
|
|
21
|
+
count = 0
|
|
22
|
+
errors = 0
|
|
23
|
+
|
|
24
|
+
original = "/exports/{0}"
|
|
25
|
+
first_duplication = "?use_labels=false"
|
|
26
|
+
second_duplication = "?use_labels=true"
|
|
27
|
+
|
|
28
|
+
# Datasets with use_labels=false are the one that were most surely impacted by the URL modifications
|
|
29
|
+
datasets = Dataset.objects(resources__url__contains=first_duplication)
|
|
30
|
+
|
|
31
|
+
log.info("Starting")
|
|
32
|
+
log.info(f"{datasets.count()} datasets to process...")
|
|
33
|
+
for dat in datasets:
|
|
34
|
+
to_save = False
|
|
35
|
+
for res_format in ["csv", "xlsx"]:
|
|
36
|
+
resources = [res for res in dat.resources if original.format(res_format) in res.url]
|
|
37
|
+
if not resources:
|
|
38
|
+
# This dataset doesn't have csv or xlsx resources
|
|
39
|
+
continue
|
|
40
|
+
if len(resources) not in [3, 4]:
|
|
41
|
+
log.info(
|
|
42
|
+
f"Skipping, {len(resources)} {res_format} duplicate resources found for {dat.id}. We're expecting 3 or 4"
|
|
43
|
+
)
|
|
44
|
+
continue
|
|
45
|
+
try:
|
|
46
|
+
res_original = next(
|
|
47
|
+
res
|
|
48
|
+
for res in resources
|
|
49
|
+
if res.url.endswith(original.format(res_format))
|
|
50
|
+
and res.title.endswith(f".{res_format}")
|
|
51
|
+
)
|
|
52
|
+
res_first_duplication = next(
|
|
53
|
+
res for res in resources if res.url.endswith(first_duplication)
|
|
54
|
+
)
|
|
55
|
+
res_second_duplication = next(
|
|
56
|
+
res for res in resources if res.url.endswith(second_duplication)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Resource that exists prior to ODS to DCAT migration and somehow did not get migrated properly
|
|
60
|
+
# cf https://github.com/opendatateam/udata-ods/pull/247
|
|
61
|
+
res_migration_duplicate = next(
|
|
62
|
+
(
|
|
63
|
+
res
|
|
64
|
+
for res in resources
|
|
65
|
+
if res.title == f"Export au format {res_format.upper()}"
|
|
66
|
+
),
|
|
67
|
+
None,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
except StopIteration:
|
|
71
|
+
log.info(
|
|
72
|
+
f"Could not find expected params on {res_format} for {dat.id} : {set(res.url.split('/')[-1] for res in resources)}"
|
|
73
|
+
)
|
|
74
|
+
errors += 1
|
|
75
|
+
continue
|
|
76
|
+
|
|
77
|
+
# Keep the original resource and update its URL
|
|
78
|
+
res_original.url += second_duplication
|
|
79
|
+
# Remove all the other duplicates
|
|
80
|
+
dat.remove_resource(res_first_duplication)
|
|
81
|
+
dat.remove_resource(res_second_duplication)
|
|
82
|
+
if res_migration_duplicate:
|
|
83
|
+
dat.remove_resource(res_migration_duplicate)
|
|
84
|
+
|
|
85
|
+
to_save = True
|
|
86
|
+
|
|
87
|
+
if to_save:
|
|
88
|
+
try:
|
|
89
|
+
dat.save()
|
|
90
|
+
count += 1
|
|
91
|
+
except ValidationError:
|
|
92
|
+
log.info(f"Could not save dataset {dat.id}")
|
|
93
|
+
log.info(traceback.format_exc())
|
|
94
|
+
errors += 1
|
|
95
|
+
|
|
96
|
+
log.info("Done !")
|
|
97
|
+
log.info(f"Updated {count} datasets. Failed on {errors} objects.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 9.2.
|
|
3
|
+
Version: 9.2.3
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -138,7 +138,12 @@ It is collectively taken care of by members of the
|
|
|
138
138
|
|
|
139
139
|
# Changelog
|
|
140
140
|
|
|
141
|
-
##
|
|
141
|
+
## 9.2.3 (2024-10-14)
|
|
142
|
+
|
|
143
|
+
- Add migration to delete duplicate resources due to ODS harvesting [#3158](https://github.com/opendatateam/udata/pull/3158)
|
|
144
|
+
- Add discussion.posted_on in discussion sort choices [3168](https://github.com/opendatateam/udata/pull/3168)
|
|
145
|
+
|
|
146
|
+
## 9.2.2 (2024-10-08)
|
|
142
147
|
|
|
143
148
|
- Add a filter on organization and document sort parameters in the `/discussions` endpoint [#3147](https://github.com/opendatateam/udata/pull/3147)
|
|
144
149
|
- Move discussion catalog creation and add fields [#3152](https://github.com/opendatateam/udata/pull/3152) and [#3154](https://github.com/opendatateam/udata/pull/3154)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
tasks/__init__.py,sha256=nubUI6ljumym4uv6NvAJEkWHtsdurFpEGSq-AxDWYDM,8153
|
|
2
2
|
tasks/helpers.py,sha256=70fS9tI_m0DTWmKx9Zl5-LG-nxdz_ZaPyvvsFkN2r48,1091
|
|
3
|
-
udata/__init__.py,sha256=
|
|
3
|
+
udata/__init__.py,sha256=pwft13dMLFAWF3NT-MhqgjA9nRu8KfeOF-x0rqj4s4Y,97
|
|
4
4
|
udata/api_fields.py,sha256=Oq0WTuI2b-TZXcxr_RExxKHT1wQYlqmDo1gKJsOfXp8,19369
|
|
5
5
|
udata/app.py,sha256=xjk2D3EgboYBpTwBwdIxd2klt2yMoWMyCrkry5fz0LA,7292
|
|
6
6
|
udata/assets.py,sha256=H5Hrc2vnKM0IFLyWfLXmJ2Kj35w1i8W1D8Cgy8_cUj4,657
|
|
@@ -108,7 +108,7 @@ udata/core/dataset/signals.py,sha256=WN4sV-lJlNsRkhcnhoy0SYJvCoYmK_5QFYZd1u-h4gs
|
|
|
108
108
|
udata/core/dataset/tasks.py,sha256=yDPK2oKSzTXfST8Up7vMd13XPEK5r6iapq7hUIow6BI,8493
|
|
109
109
|
udata/core/discussions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
110
110
|
udata/core/discussions/actions.py,sha256=seKxsKut6xLkobfC2Yy2wpD_-flsT8HcFPcN6SDpz6k,789
|
|
111
|
-
udata/core/discussions/api.py,sha256=
|
|
111
|
+
udata/core/discussions/api.py,sha256=5yMdKeWp0c9H2ipy5bXoMf82r3ULMIARhvuIdM-XJp0,9446
|
|
112
112
|
udata/core/discussions/constants.py,sha256=nbZgXESpg0TykIGPxW8xUtHtk7TwQoyOL0Ky4U4B7c8,27
|
|
113
113
|
udata/core/discussions/csv.py,sha256=c7ZHMicIi8R0kvMjnsUooO0WlH0t90hJ9kO2mmFnUM0,672
|
|
114
114
|
udata/core/discussions/factories.py,sha256=CgQaUmmyDu90XtyBsqXVa-TmZMrN7Dwuu1Cnr5wNrVc,350
|
|
@@ -347,6 +347,7 @@ udata/migrations/2023-02-08-rename-internal-dates.py,sha256=jE1oR16Zc98450mATKpK
|
|
|
347
347
|
udata/migrations/2024-01-29-fix-reuse-and-dataset-with-private-None.py,sha256=9LMwAdv7527qsrQQikZAskFsheqwZpEP_VewjwROm6o,592
|
|
348
348
|
udata/migrations/2024-03-22-migrate-activity-kwargs-to-extras.py,sha256=ucoXSqZlGToMCNiba0pRw_WoYb-lSBKvnbBLe-YVVrs,402
|
|
349
349
|
udata/migrations/2024-06-11-fix-reuse-datasets-references.py,sha256=p0ksSutxk93rY9AMPyN7w_9lU5Y3sRU75iWOLR8MmsY,768
|
|
350
|
+
udata/migrations/2024-10-01-remove-ods-duplicates.py,sha256=e7u0oGUxFgp4_cmxJlEpWZtKp2gn6T1tVYrQgb6V2wo,3621
|
|
350
351
|
udata/migrations/__init__.py,sha256=RBCBDaTlLjuMs_Qzwji6Z6T4r7FCGXhESKoxQbT5qAA,11221
|
|
351
352
|
udata/models/__init__.py,sha256=txbZwa-lRG3mq99eQ9E5YcFWiNUdjDVSyJJvlqUMFfs,1413
|
|
352
353
|
udata/mongo/__init__.py,sha256=y4Rv-kq3o_kcEulcNpePLzocXPBNpx3Jd82G-VZPaMc,1421
|
|
@@ -698,9 +699,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=3ICJrrfuylqcmgkWApGylKGYLKKmcC
|
|
|
698
699
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=AnLimXvln78bzu8GHq6rj9Xp0LjewKi-yJrrtHzi7d4,44645
|
|
699
700
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=SqzVRRevggMrUyGUxFyvf8Shf3GHDDeCpLFzr7oHI9o,28163
|
|
700
701
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=Bfj0FURHtLPxBHrXpUDmJHgM9vslS_VTyGUgXVjfuM8,51137
|
|
701
|
-
udata-9.2.
|
|
702
|
-
udata-9.2.
|
|
703
|
-
udata-9.2.
|
|
704
|
-
udata-9.2.
|
|
705
|
-
udata-9.2.
|
|
706
|
-
udata-9.2.
|
|
702
|
+
udata-9.2.3.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
703
|
+
udata-9.2.3.dist-info/METADATA,sha256=o04kwCcLHDez5LZGH9kOsWRhViWU0T97-Yl_8wZxL4g,131766
|
|
704
|
+
udata-9.2.3.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
|
|
705
|
+
udata-9.2.3.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
|
|
706
|
+
udata-9.2.3.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
707
|
+
udata-9.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|