udata 6.1.8.dev26107__py2.py3-none-any.whl → 6.1.8.dev26180__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.

@@ -4,7 +4,7 @@ import click
4
4
 
5
5
  from flask import current_app
6
6
 
7
- from udata.commands import cli, success, echo, white
7
+ from udata.commands import cli, success
8
8
  from udata.models import User, Dataset, Reuse, Organization, Site
9
9
 
10
10
  log = logging.getLogger(__name__)
@@ -43,6 +43,7 @@ def update(site=False, organizations=False, users=False, datasets=False,
43
43
  site.count_reuses()
44
44
  site.count_followers()
45
45
  site.count_discussions()
46
+ site.count_harvesters()
46
47
  site.count_max_dataset_followers()
47
48
  site.count_max_dataset_reuses()
48
49
  site.count_max_reuse_datasets()
@@ -53,7 +54,6 @@ def update(site=False, organizations=False, users=False, datasets=False,
53
54
  except Exception as e:
54
55
  log.info(f'Error during update: {e}')
55
56
 
56
-
57
57
  if do_all or datasets:
58
58
  log.info('Update datasets metrics')
59
59
  all_datasets = Dataset.objects.visible().timeout(False)
@@ -4,6 +4,7 @@ from udata.models import Site
4
4
  from udata.tasks import job
5
5
  from udata.core.metrics.signals import on_site_metrics_computed
6
6
 
7
+
7
8
  @job('compute-site-metrics')
8
9
  def compute_site_metrics(self):
9
10
  site = Site.objects(id=current_app.config['SITE_ID']).first()
@@ -14,6 +15,7 @@ def compute_site_metrics(self):
14
15
  site.count_reuses()
15
16
  site.count_followers()
16
17
  site.count_discussions()
18
+ site.count_harvesters()
17
19
  site.count_max_dataset_followers()
18
20
  site.count_max_dataset_reuses()
19
21
  site.count_max_reuse_datasets()
udata/core/site/models.py CHANGED
@@ -43,6 +43,7 @@ class Site(WithMetrics, db.Document):
43
43
  'resources',
44
44
  'reuses',
45
45
  'users',
46
+ 'harvesters'
46
47
  ]
47
48
 
48
49
  def __str__(self):
@@ -71,7 +72,7 @@ class Site(WithMetrics, db.Document):
71
72
  def count_resources(self):
72
73
  self.metrics['resources'] = next(Dataset.objects.visible().aggregate(
73
74
  {'$project': {'resources': 1}},
74
- {'$unwind': '$resources' },
75
+ {'$unwind': '$resources'},
75
76
  {'$group': {'_id': 'result', 'count': {'$sum': 1}}}
76
77
  ), {}).get('count', 0)
77
78
  self.save()
@@ -90,6 +91,11 @@ class Site(WithMetrics, db.Document):
90
91
  self.metrics['discussions'] = Discussion.objects.count()
91
92
  self.save()
92
93
 
94
+ def count_harvesters(self):
95
+ from udata.harvest.models import HarvestSource
96
+ self.metrics['harvesters'] = HarvestSource.objects().count()
97
+ self.save()
98
+
93
99
  def count_max_dataset_followers(self):
94
100
  dataset = (Dataset.objects(metrics__followers__gt=0).visible()
95
101
  .order_by('-metrics.followers').first())
@@ -98,7 +104,7 @@ class Site(WithMetrics, db.Document):
98
104
 
99
105
  def count_max_dataset_reuses(self):
100
106
  dataset = (Dataset.objects(metrics__reuses__gt=0).visible()
101
- .order_by('-metrics.reuses').first())
107
+ .order_by('-metrics.reuses').first())
102
108
  self.metrics['max_dataset_reuses'] = dataset.metrics['reuses'] if dataset else 0
103
109
  self.save()
104
110
 
udata/core/topic/api.py CHANGED
@@ -1,5 +1,4 @@
1
1
  from udata.api import api, fields, API
2
- from udata.auth import admin_permission
3
2
 
4
3
 
5
4
  from udata.core.dataset.api_fields import dataset_fields
@@ -63,7 +62,6 @@ class TopicsAPI(API):
63
62
  .paginate(args['page'], args['page_size']))
64
63
 
65
64
  @api.doc('create_topic')
66
- @api.secure(admin_permission)
67
65
  @api.expect(topic_fields)
68
66
  @api.marshal_with(topic_fields)
69
67
  @api.response(400, 'Validation error')
@@ -84,7 +82,6 @@ class TopicAPI(API):
84
82
  return topic
85
83
 
86
84
  @api.doc('update_topic')
87
- @api.secure(admin_permission)
88
85
  @api.expect(topic_fields)
89
86
  @api.marshal_with(topic_fields)
90
87
  @api.response(400, 'Validation error')
@@ -94,7 +91,6 @@ class TopicAPI(API):
94
91
  return form.save()
95
92
 
96
93
  @api.doc('delete_topic')
97
- @api.secure(admin_permission)
98
94
  @api.response(204, 'Object deleted')
99
95
  def delete(self, topic):
100
96
  '''Delete a given topic'''