Skip to content

Commit

Permalink
naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
amdomanska committed Apr 20, 2023
1 parent 0f14270 commit 3626676
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions portality/bll/doaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def backgroundTaskStatusService(cls):
return background_task_status.BackgroundTaskStatusService()

@classmethod
def concurrencyPreventionService(cls, **kwargs):
def ConcurrencyPreventionService(cls, **kwargs):
"""
Obtain an instance of the concurrency_prevention service
~~->Concurrency_Prevention:Service~~
:return: updateRequestConcurrencyPreventionService
:return: UpdateRequestConcurrencyPreventionService
"""
from portality.bll.services import concurrency_prevention
return concurrency_prevention.concurrencyPreventionService(**kwargs)
return concurrency_prevention.ConcurrencyPreventionService(**kwargs)
10 changes: 5 additions & 5 deletions portality/bll/services/concurrency_prevention.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
import redis


class concurrencyPreventionService(object):
class ConcurrencyPreventionService(object):
def __init__(self, **kwargs):
self.rs = redis.Redis(host=app.config.get("HUEY_REDIS_HOST"), port=app.config.get("HUEY_REDIS_PORT"))
self.context = kwargs["context"]
self.kwargs = dict(kwargs)

def prevent_concurrency(self, **kwargs):
def preventConcurrency(self, **kwargs):
if (self.context == "article"):
return
if (self.context == "update_request"):
return updateRequestConcurrencyPreventionService(redis_service=self.rs, **self.kwargs).prevent_concurrency()
return UpdateRequestConcurrencyPreventionService(redis_service=self.rs, **self.kwargs).preventConcurrency()


class updateRequestConcurrencyPreventionService(object):
class UpdateRequestConcurrencyPreventionService(object):
def __init__(self, redis_service, **kwargs):
self.journal = kwargs["journal"]
self.id = kwargs["id"]
self.rs = redis_service

def prevent_concurrency(self):
def preventConcurrency(self):
aid = self.rs.get(self.journal)
if aid is not None and aid != self.id:
raise ConcurrentUpdateRequestException(Messages.CONCURRENT_UPDATE_REQUEST)
Expand Down
4 changes: 2 additions & 2 deletions portality/models/v2/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def save(self, sync_owner=True, **kwargs):

if self.application_type == constants.APPLICATION_TYPE_UPDATE_REQUEST:
# ~~-> Concurrency_Prevention:Service ~~
cs = DOAJ.concurrencyPreventionService(journal=self.current_journal, id=self.id, context="update_request")
cs.prevent_concurrency()
cs = DOAJ.ConcurrencyPreventionService(journal=self.current_journal, id=self.id, context="update_request")
cs.preventConcurrency()

self.prep()
self.verify_against_struct()
Expand Down

0 comments on commit 3626676

Please sign in to comment.