udata 10.4.2.dev35427__py2.py3-none-any.whl → 10.4.2.dev35441__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/user/activities.py +0 -5
- udata/migrations/2025-05-22-purge-duplicate-activities.py +101 -0
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/METADATA +2 -1
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/RECORD +8 -7
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/LICENSE +0 -0
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/WHEEL +0 -0
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/entry_points.txt +0 -0
- {udata-10.4.2.dev35427.dist-info → udata-10.4.2.dev35441.dist-info}/top_level.txt +0 -0
udata/core/user/activities.py
CHANGED
|
@@ -30,11 +30,6 @@ class DiscussActivity(object):
|
|
|
30
30
|
badge_type = "warning"
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
class UserStarredOrganization(FollowActivity, OrgRelatedActivity, Activity):
|
|
34
|
-
key = "organization:followed"
|
|
35
|
-
label = _("followed an organization")
|
|
36
|
-
|
|
37
|
-
|
|
38
33
|
class UserFollowedUser(FollowActivity, Activity):
|
|
39
34
|
key = "user:followed"
|
|
40
35
|
label = _("followed a user")
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This migration updates Topic.featured to False when it is None.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from datetime import datetime, timedelta
|
|
7
|
+
|
|
8
|
+
from mongoengine.connection import get_db
|
|
9
|
+
|
|
10
|
+
from udata.core.dataset.activities import UserCreatedDataset, UserDeletedDataset, UserUpdatedDataset
|
|
11
|
+
from udata.core.organization.activities import UserUpdatedOrganization
|
|
12
|
+
from udata.core.reuse.activities import UserCreatedReuse, UserDeletedReuse, UserUpdatedReuse
|
|
13
|
+
from udata.core.user.activities import (
|
|
14
|
+
UserDiscussedDataset,
|
|
15
|
+
UserDiscussedReuse,
|
|
16
|
+
UserFollowedDataset,
|
|
17
|
+
UserFollowedOrganization,
|
|
18
|
+
UserFollowedReuse,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def migrate(db):
|
|
25
|
+
# Remove legacy fields (`as_organization`, `kwargs`) from old activities
|
|
26
|
+
result = get_db().activity.update_many({}, {"$unset": {"as_organization": ""}})
|
|
27
|
+
log.info(
|
|
28
|
+
f"Legacy field `as_organization` removed from {result.modified_count} activity objects"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
result = get_db().activity.update_many({}, {"$unset": {"kwargs": ""}})
|
|
32
|
+
log.info(f"Legacy field `kwargs` removed from {result.modified_count} activity objects")
|
|
33
|
+
|
|
34
|
+
# Clean duplicate activities in case of discussion or following
|
|
35
|
+
# - remove the "updated" activity on the discussed/followed object
|
|
36
|
+
# - remove the activity on the organization
|
|
37
|
+
# The heuristic is to look for specific activities by the same actor on the targeted object
|
|
38
|
+
# within a -1 +1 second timespan
|
|
39
|
+
for action_related_activity, object_updated_activity in [
|
|
40
|
+
(UserDiscussedDataset, UserUpdatedDataset),
|
|
41
|
+
(UserDiscussedReuse, UserUpdatedReuse),
|
|
42
|
+
(UserFollowedDataset, UserUpdatedDataset),
|
|
43
|
+
(UserFollowedReuse, UserUpdatedReuse),
|
|
44
|
+
]:
|
|
45
|
+
org_activity_count = 0
|
|
46
|
+
object_activity_count = 0
|
|
47
|
+
activities = (
|
|
48
|
+
action_related_activity.objects()
|
|
49
|
+
.no_dereference() # We use no_dereference in query to prevent DBref DoesNotExist errors
|
|
50
|
+
.no_cache()
|
|
51
|
+
.timeout(False)
|
|
52
|
+
)
|
|
53
|
+
log.info(
|
|
54
|
+
f"{datetime.utcnow()}: Processing {activities.count()} {action_related_activity} activities..."
|
|
55
|
+
)
|
|
56
|
+
for act in activities:
|
|
57
|
+
object_activity_count += object_updated_activity.objects(
|
|
58
|
+
actor=act.actor.id,
|
|
59
|
+
related_to=act.related_to.id,
|
|
60
|
+
created_at__gte=act.created_at - timedelta(seconds=1),
|
|
61
|
+
created_at__lte=act.created_at + timedelta(seconds=1),
|
|
62
|
+
).delete()
|
|
63
|
+
if act.organization:
|
|
64
|
+
org_activity_count += UserUpdatedOrganization.objects(
|
|
65
|
+
actor=act.actor.id,
|
|
66
|
+
related_to=act.organization,
|
|
67
|
+
created_at__gte=act.created_at - timedelta(seconds=1),
|
|
68
|
+
created_at__lte=act.created_at + timedelta(seconds=1),
|
|
69
|
+
).delete()
|
|
70
|
+
log.info(
|
|
71
|
+
f"{datetime.utcnow()}: Deleted {object_activity_count} {object_updated_activity} and {org_activity_count} UserUpdatedOrganization activities"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Clean duplicated UserUpdatedOrganization activities on organization for any object related activity
|
|
75
|
+
for object_related_activity in [
|
|
76
|
+
UserCreatedDataset,
|
|
77
|
+
UserUpdatedDataset,
|
|
78
|
+
UserDeletedDataset,
|
|
79
|
+
UserCreatedReuse,
|
|
80
|
+
UserUpdatedReuse,
|
|
81
|
+
UserDeletedReuse,
|
|
82
|
+
UserFollowedOrganization,
|
|
83
|
+
]:
|
|
84
|
+
count = 0
|
|
85
|
+
activities = (
|
|
86
|
+
object_related_activity.objects(organization__exists=True)
|
|
87
|
+
.no_dereference() # We use no_dereference in query to prevent DBref DoesNotExist errors
|
|
88
|
+
.no_cache()
|
|
89
|
+
.timeout(False)
|
|
90
|
+
)
|
|
91
|
+
log.info(
|
|
92
|
+
f"{datetime.utcnow()}: Processing {activities.count()} {object_related_activity} activities..."
|
|
93
|
+
)
|
|
94
|
+
for act in activities:
|
|
95
|
+
count += UserUpdatedOrganization.objects(
|
|
96
|
+
actor=act.actor.id,
|
|
97
|
+
related_to=act.organization,
|
|
98
|
+
created_at__gte=act.created_at - timedelta(seconds=1),
|
|
99
|
+
created_at__lte=act.created_at + timedelta(seconds=1),
|
|
100
|
+
).delete()
|
|
101
|
+
log.info(f"{datetime.utcnow()}: Deleted {count} UserUpdatedOrganization activities")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 10.4.2.
|
|
3
|
+
Version: 10.4.2.dev35441
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -144,6 +144,7 @@ It is collectively taken care of by members of the
|
|
|
144
144
|
- Add test for removing last contact point [#3322](https://github.com/opendatateam/udata/pull/3322)
|
|
145
145
|
- Add activities to dataservices and resources, add Auditable class to refactor improve code [#3308](https://github.com/opendatateam/udata/pull/3308)
|
|
146
146
|
- Store activities for private objects [#3328](https://github.com/opendatateam/udata/pull/3328)
|
|
147
|
+
- :warning: Add migration to clean duplicate activities [#3327](https://github.com/opendatateam/udata/pull/3327)
|
|
147
148
|
- Do not crash if file doesn't exists during resource deletion [#3323](https://github.com/opendatateam/udata/pull/3323)
|
|
148
149
|
- Show user domain in suggest [#3324](https://github.com/opendatateam/udata/pull/3324)
|
|
149
150
|
- Keep the existing frequency if not found during harvesting [#3330](https://github.com/opendatateam/udata/pull/3330)
|
|
@@ -237,7 +237,7 @@ udata/core/topic/models.py,sha256=X-jScC_mMNdZp0hQ_SD-NBHsIPS8aYqpq99x6l4dKz4,20
|
|
|
237
237
|
udata/core/topic/parsers.py,sha256=ugkBd-w8TewInqowNF2w36UPwKYMYluK4U-grkAu-wg,2411
|
|
238
238
|
udata/core/topic/permissions.py,sha256=RtFPPlxuU_Bv7ip6LDO4AoPrKFnIOEs9cCMXaSSmEdk,118
|
|
239
239
|
udata/core/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
240
|
-
udata/core/user/activities.py,sha256=
|
|
240
|
+
udata/core/user/activities.py,sha256=d91G45XEgoxYUJetkSjVolSM-nqmNSuM5b-6geayGE4,3338
|
|
241
241
|
udata/core/user/api.py,sha256=TO5iolYhb7wWSqBwrSHQOSYR-r_8Jrn4LtMF5BiQELk,13473
|
|
242
242
|
udata/core/user/api_fields.py,sha256=S4wONsS5p_Ys31HdBxS_hBreCFHEegjfagg5aprwkNA,6026
|
|
243
243
|
udata/core/user/apiv2.py,sha256=4eNsvJjb4ChJQFrXtVbkOtAvXEcQcQpZf8vkEbriXRA,1125
|
|
@@ -365,6 +365,7 @@ udata/migrations/2024-12-05-contact-point-is-now-a-list.py,sha256=il2qSFhOTq-Yhq
|
|
|
365
365
|
udata/migrations/2025-01-05-dataservices-fields-changes.py,sha256=HlqHg3sG3rk3sYVrOwAlXMNhTmTKd1YT82P-gXOqmZM,4647
|
|
366
366
|
udata/migrations/2025-03-20-save-quality-for-datasets.py,sha256=FPTfGVByXSHr18V4RFlktC7t-H-5rgEcZQMTRpMrGqo,607
|
|
367
367
|
udata/migrations/2025-04-24-topic-featured-default-false.py,sha256=t4OyhehtPQiosKtAo9SWRWm3ObGUHvqD_roXQ34vIH4,369
|
|
368
|
+
udata/migrations/2025-05-22-purge-duplicate-activities.py,sha256=iemQwEWtbxedtpkeTFIeoNP7WcY7ntnDrjUClPzzWfg,4212
|
|
368
369
|
udata/migrations/__init__.py,sha256=RBCBDaTlLjuMs_Qzwji6Z6T4r7FCGXhESKoxQbT5qAA,11221
|
|
369
370
|
udata/models/__init__.py,sha256=txbZwa-lRG3mq99eQ9E5YcFWiNUdjDVSyJJvlqUMFfs,1413
|
|
370
371
|
udata/mongo/__init__.py,sha256=y4Rv-kq3o_kcEulcNpePLzocXPBNpx3Jd82G-VZPaMc,1421
|
|
@@ -727,9 +728,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=ViV14tUmjSydHS0TWG_mFikKQfyUaT
|
|
|
727
728
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=rzAD_MVoV54TmN3w1ECz3H2Ru5pM7hWMVH03SkY28Q8,47250
|
|
728
729
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=EHX1_D-Uglj38832G7BrA0QC5IuY3p8dKqi9T0DgPmE,29169
|
|
729
730
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=3PMnbVhKVJh6Q8ABi1ZTZ8Dcf-sMjngLJZqLbonJoec,54225
|
|
730
|
-
udata-10.4.2.
|
|
731
|
-
udata-10.4.2.
|
|
732
|
-
udata-10.4.2.
|
|
733
|
-
udata-10.4.2.
|
|
734
|
-
udata-10.4.2.
|
|
735
|
-
udata-10.4.2.
|
|
731
|
+
udata-10.4.2.dev35441.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
732
|
+
udata-10.4.2.dev35441.dist-info/METADATA,sha256=kKLW5dRSdxUIexOLVuiXwKXqEGbH9k1LBzUH4j8gMOQ,147267
|
|
733
|
+
udata-10.4.2.dev35441.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
|
|
734
|
+
udata-10.4.2.dev35441.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
|
|
735
|
+
udata-10.4.2.dev35441.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
736
|
+
udata-10.4.2.dev35441.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|