udata 10.1.3.dev34219__py2.py3-none-any.whl → 10.1.3.dev34251__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.

Files changed (27) hide show
  1. udata/core/dataservices/models.py +11 -5
  2. udata/core/dataservices/search.py +2 -3
  3. udata/core/metrics/commands.py +20 -1
  4. udata/static/chunks/{10.8ca60413647062717b1e.js → 10.471164b2a9fe15614797.js} +3 -3
  5. udata/static/chunks/{10.8ca60413647062717b1e.js.map → 10.471164b2a9fe15614797.js.map} +1 -1
  6. udata/static/chunks/{11.b6f741fcc366abfad9c4.js → 11.51d706fb9521c16976bc.js} +3 -3
  7. udata/static/chunks/{11.b6f741fcc366abfad9c4.js.map → 11.51d706fb9521c16976bc.js.map} +1 -1
  8. udata/static/chunks/{13.2d06442dd9a05d9777b5.js → 13.f29411b06be1883356a3.js} +2 -2
  9. udata/static/chunks/{13.2d06442dd9a05d9777b5.js.map → 13.f29411b06be1883356a3.js.map} +1 -1
  10. udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js → 17.3bd0340930d4a314ce9c.js} +2 -2
  11. udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js.map → 17.3bd0340930d4a314ce9c.js.map} +1 -1
  12. udata/static/chunks/{19.f03a102365af4315f9db.js → 19.8da42e8359d72afc2618.js} +3 -3
  13. udata/static/chunks/{19.f03a102365af4315f9db.js.map → 19.8da42e8359d72afc2618.js.map} +1 -1
  14. udata/static/chunks/{8.778091d55cd8ea39af6b.js → 8.54e44b102164ae5e7a67.js} +2 -2
  15. udata/static/chunks/{8.778091d55cd8ea39af6b.js.map → 8.54e44b102164ae5e7a67.js.map} +1 -1
  16. udata/static/chunks/{9.033d7e190ca9e226a5d0.js → 9.07515e5187f475bce828.js} +3 -3
  17. udata/static/chunks/{9.033d7e190ca9e226a5d0.js.map → 9.07515e5187f475bce828.js.map} +1 -1
  18. udata/static/common.js +1 -1
  19. udata/static/common.js.map +1 -1
  20. udata/tests/api/test_dataservices_api.py +26 -2
  21. udata/tests/dataservice/test_csv_adapter.py +2 -0
  22. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/METADATA +2 -1
  23. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/RECORD +27 -27
  24. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/LICENSE +0 -0
  25. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/WHEEL +0 -0
  26. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/entry_points.txt +0 -0
  27. {udata-10.1.3.dev34219.dist-info → udata-10.1.3.dev34251.dist-info}/top_level.txt +0 -0
@@ -100,11 +100,17 @@ class HarvestMetadata(db.EmbeddedDocument):
100
100
  @generate_fields(
101
101
  searchable=True,
102
102
  additional_filters={"organization_badge": "organization.badges"},
103
+ additional_sorts=[
104
+ {"key": "followers", "value": "metrics.followers"},
105
+ {"key": "views", "value": "metrics.views"},
106
+ ],
103
107
  )
104
108
  class Dataservice(WithMetrics, Owned, db.Document):
105
109
  meta = {
106
110
  "indexes": [
107
111
  "$title",
112
+ "metrics.followers",
113
+ "metrics.views",
108
114
  ]
109
115
  + Owned.meta["indexes"],
110
116
  "queryset_class": DataserviceQuerySet,
@@ -223,11 +229,11 @@ class Dataservice(WithMetrics, Owned, db.Document):
223
229
  def self_web_url(self):
224
230
  return endpoint_for("dataservices.show", dataservice=self, _external=True)
225
231
 
226
- # TODO
227
- # frequency = db.StringField(choices=list(UPDATE_FREQUENCIES.keys()))
228
- # temporal_coverage = db.EmbeddedDocumentField(db.DateRange)
229
- # spatial = db.EmbeddedDocumentField(SpatialCoverage)
230
- # harvest = db.EmbeddedDocumentField(HarvestDatasetMetadata)
232
+ __metrics_keys__ = [
233
+ "discussions",
234
+ "followers",
235
+ "views",
236
+ ]
231
237
 
232
238
  @property
233
239
  def is_hidden(self):
@@ -56,9 +56,7 @@ class DataserviceSearch(ModelSearchAdapter):
56
56
  model = Dataservice
57
57
  search_url = "dataservices/"
58
58
 
59
- sorts = {
60
- "created": "created_at",
61
- }
59
+ sorts = {"created": "created_at", "views": "views", "followers": "followers"}
62
60
 
63
61
  filters = {
64
62
  "tag": Filter(),
@@ -114,5 +112,6 @@ class DataserviceSearch(ModelSearchAdapter):
114
112
  "tags": dataservice.tags,
115
113
  "extras": extras,
116
114
  "followers": dataservice.metrics.get("followers", 0),
115
+ "views": dataservice.metrics.get("views", 0),
117
116
  "is_restricted": dataservice.is_restricted or False,
118
117
  }
@@ -4,6 +4,7 @@ import click
4
4
  from flask import current_app
5
5
 
6
6
  from udata.commands import cli, success
7
+ from udata.core.dataservices.models import Dataservice
7
8
  from udata.models import Dataset, GeoZone, Organization, Reuse, Site, User
8
9
 
9
10
  log = logging.getLogger(__name__)
@@ -19,6 +20,7 @@ def grp():
19
20
  @click.option("-s", "--site", is_flag=True, help="Update site metrics")
20
21
  @click.option("-o", "--organizations", is_flag=True, help="Compute organizations metrics")
21
22
  @click.option("-d", "--datasets", is_flag=True, help="Compute datasets metrics")
23
+ @click.option("--dataservices", is_flag=True, help="Compute dataservices metrics")
22
24
  @click.option("-r", "--reuses", is_flag=True, help="Compute reuses metrics")
23
25
  @click.option("-u", "--users", is_flag=True, help="Compute users metrics")
24
26
  @click.option("-g", "--geozones", is_flag=True, help="Compute geo levels metrics")
@@ -28,12 +30,13 @@ def update(
28
30
  organizations=False,
29
31
  users=False,
30
32
  datasets=False,
33
+ dataservices=False,
31
34
  reuses=False,
32
35
  geozones=False,
33
36
  drop=False,
34
37
  ):
35
38
  """Update all metrics for the current date"""
36
- do_all = not any((site, organizations, users, datasets, reuses, geozones))
39
+ do_all = not any((site, organizations, users, datasets, dataservices, reuses, geozones))
37
40
 
38
41
  if do_all or site:
39
42
  log.info("Update site metrics")
@@ -75,6 +78,22 @@ def update(
75
78
  log.info(f"Error during update: {e}")
76
79
  continue
77
80
 
81
+ if do_all or dataservices:
82
+ log.info("Update dataservices metrics")
83
+ all_dataservices = Dataservice.objects.visible().timeout(False)
84
+ with click.progressbar(
85
+ all_dataservices, length=Dataservice.objects.count()
86
+ ) as dataservice_bar:
87
+ for dataservice in dataservice_bar:
88
+ try:
89
+ if drop:
90
+ dataservice.metrics.clear()
91
+ dataservice.count_discussions()
92
+ dataservice.count_followers()
93
+ except Exception as e:
94
+ log.info(f"Error during update: {e}")
95
+ continue
96
+
78
97
  if do_all or reuses:
79
98
  log.info("Update reuses metrics")
80
99
  all_reuses = Reuse.objects.visible().timeout(False)