mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 00:19:15 +00:00
explicitly mark helper functions private
I thought about making them private class members, but that would get unreadable and do more harm than good.
This commit is contained in:
parent
870d2c408d
commit
14c4ae26ab
|
@ -98,7 +98,7 @@ class Jobs:
|
|||
result=None,
|
||||
)
|
||||
r = RedisPool().get_connection()
|
||||
store_job_as_hash(r, redis_key_from_uuid(job.uid), job)
|
||||
_store_job_as_hash(r, _redis_key_from_uuid(job.uid), job)
|
||||
return job
|
||||
|
||||
@staticmethod
|
||||
|
@ -114,7 +114,7 @@ class Jobs:
|
|||
Remove a job from the jobs list.
|
||||
"""
|
||||
r = RedisPool().get_connection()
|
||||
key = redis_key_from_uuid(job_uuid)
|
||||
key = _redis_key_from_uuid(job_uuid)
|
||||
r.delete(key)
|
||||
return False
|
||||
|
||||
|
@ -148,9 +148,9 @@ class Jobs:
|
|||
job.finished_at = datetime.datetime.now()
|
||||
|
||||
r = RedisPool().get_connection()
|
||||
key = redis_key_from_uuid(job.uid)
|
||||
key = _redis_key_from_uuid(job.uid)
|
||||
if r.exists(key):
|
||||
store_job_as_hash(r, key, job)
|
||||
_store_job_as_hash(r, key, job)
|
||||
if status in (JobStatus.FINISHED, JobStatus.ERROR):
|
||||
r.expire(key, JOB_EXPIRATION_SECONDS)
|
||||
|
||||
|
@ -162,9 +162,9 @@ class Jobs:
|
|||
Get a job from the jobs list.
|
||||
"""
|
||||
r = RedisPool().get_connection()
|
||||
key = redis_key_from_uuid(uid)
|
||||
key = _redis_key_from_uuid(uid)
|
||||
if r.exists(key):
|
||||
return job_from_hash(r, key)
|
||||
return _job_from_hash(r, key)
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
@ -174,7 +174,7 @@ class Jobs:
|
|||
"""
|
||||
r = RedisPool().get_connection()
|
||||
jobs = r.keys("jobs:*")
|
||||
return [job_from_hash(r, job_key) for job_key in jobs]
|
||||
return [_job_from_hash(r, job_key) for job_key in jobs]
|
||||
|
||||
@staticmethod
|
||||
def is_busy() -> bool:
|
||||
|
@ -187,11 +187,11 @@ class Jobs:
|
|||
return False
|
||||
|
||||
|
||||
def redis_key_from_uuid(uuid):
|
||||
def _redis_key_from_uuid(uuid):
|
||||
return "jobs:" + str(uuid)
|
||||
|
||||
|
||||
def store_job_as_hash(r, redis_key, model):
|
||||
def _store_job_as_hash(r, redis_key, model):
|
||||
for key, value in model.dict().items():
|
||||
if isinstance(value, uuid.UUID):
|
||||
value = str(value)
|
||||
|
@ -202,7 +202,7 @@ def store_job_as_hash(r, redis_key, model):
|
|||
r.hset(redis_key, key, str(value))
|
||||
|
||||
|
||||
def job_from_hash(r, redis_key):
|
||||
def _job_from_hash(r, redis_key):
|
||||
if r.exists(redis_key):
|
||||
job_dict = r.hgetall(redis_key)
|
||||
for date in [
|
||||
|
|
Loading…
Reference in a new issue