Skip to content

Commit

Permalink
fix usage metrics storing for ingest items (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek authored Sep 19, 2023
1 parent 8a885b0 commit e45e73f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions apps/usage_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ class UsageMetricsResource(superdesk.Resource):
class UsageMetricsService(superdesk.Service):
def on_created(self, docs):
for doc in docs:
archive_service = superdesk.get_resource_service("archive")
item = archive_service.find_one(req=None, _id=doc["item"])
archive_service.system_update(
item["_id"],
{"$inc": {f"metrics.{doc['action']}": 1}},
item,
change_request=True,
push_notification=False,
)
for resource in ["archive", "ingest"]:
service = superdesk.get_resource_service(resource)
item = service.find_one(req=None, _id=doc["item"])
if not item:
continue
service.system_update(
item["_id"],
{"$inc": {f"metrics.{doc['action']}": 1}},
item,
change_request=True,
push_notification=False,
)
return super().on_created(docs)


Expand Down

0 comments on commit e45e73f

Please sign in to comment.