queue-local 0.0.46__tar.gz → 0.0.48__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: queue-local
3
- Version: 0.0.46
3
+ Version: 0.0.48
4
4
  Home-page: https://github.com/circles-zone/queue-local-python-package
5
5
  Author: Circles
6
6
  Author-email: info@circles.life
@@ -84,9 +84,14 @@ class DatabaseQueue(OurQueue, GenericCRUD, metaclass=MetaLogger, object=queue_lo
84
84
  id_column_value = data_json[self.id_column_name]
85
85
  del data_json[self.id_column_name]
86
86
  self.update_by_id(id_column_value=id_column_value, data_json=data_json)
87
+ # TODO push_result = id_column_value
87
88
  return id_column_value
88
89
  else:
90
+ # TODO push_result = elf.insert(data_json=data_json)
89
91
  return self.insert(data_json=data_json)
92
+ # TODO Can we do this everywhere?
93
+ # TODO logger.end("...", {'push_result': push_result} )
94
+ # TODO return push_result
90
95
 
91
96
  def push_back(self, queue_item: dict) -> None:
92
97
  """Push a taken queue item back to the queue."""
@@ -105,13 +110,15 @@ class DatabaseQueue(OurQueue, GenericCRUD, metaclass=MetaLogger, object=queue_lo
105
110
  action_ids = self._fix_action_ids(action_ids)
106
111
 
107
112
  data_json = {"process_id": os.getpid()}
108
- update_where = f"process_id IS NULL AND queue_status_id = {QueueStatusEnum.NEW.value} AND " \
109
- f"NOW() > start_timestamp AND (end_timestamp is NULL or NOW() < end_timestamp) " + \
113
+ update_where = f"process_id IS NULL " \
114
+ f"AND (queue_status_id IS NULL OR queue_status_id = {QueueStatusEnum.NEW.value}) " \
115
+ f"AND NOW() > start_timestamp AND (end_timestamp is NULL or NOW() < end_timestamp) " + \
110
116
  (f"AND action_id IN {action_ids} " if action_ids else "") + \
111
117
  (f"AND {custom_condition}" if custom_condition else "")
112
118
  self.update_by_where(where=update_where, order_by=self.id_column_name, limit=1, data_json=data_json)
113
119
 
114
- select_where = f"process_id = {os.getpid()} AND queue_status_id = {QueueStatusEnum.NEW.value}"
120
+ # TODO In which cases queue_status_id IS NULL? - Does it indicate a problem/bug?
121
+ select_where = f"process_id = {os.getpid()} AND (queue_status_id IS NULL OR queue_status_id = {QueueStatusEnum.NEW.value})"
115
122
  queue_item = self.select_one_dict_by_where(where=select_where)
116
123
  if queue_item:
117
124
  # Update the selected queue item
@@ -131,7 +138,8 @@ class DatabaseQueue(OurQueue, GenericCRUD, metaclass=MetaLogger, object=queue_lo
131
138
  def peek(self, action_ids: tuple = ()) -> dict:
132
139
  """Get the first item in the queue without changing it"""
133
140
  action_ids = self._fix_action_ids(action_ids)
134
- where = f"process_id IS NULL AND queue_status_id = {QueueStatusEnum.NEW.value}" + \
141
+ # TODO In which cases queue_status_id IS NULL? - Does it indicate a problem/bug?
142
+ where = f"process_id IS NULL AND (queue_status_id IS NULL OR queue_status_id = {QueueStatusEnum.NEW.value})" + \
135
143
  (f" AND action_id IN {action_ids}" if action_ids else "")
136
144
  # SELECT * FROM `queue`.`queue_item_view` WHERE process_id IS NULL AND queue_status_id = 0
137
145
  # AND action_id IN (1, 2, 3) ORDER BY queue_item_id LIMIT 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: queue-local
3
- Version: 0.0.46
3
+ Version: 0.0.48
4
4
  Home-page: https://github.com/circles-zone/queue-local-python-package
5
5
  Author: Circles
6
6
  Author-email: info@circles.life
@@ -5,7 +5,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
5
5
 
6
6
  setuptools.setup(
7
7
  name=PACKAGE_NAME, # https://pypi.org/project/queue-local
8
- version='0.0.46',
8
+ version='0.0.48',
9
9
  author="Circles",
10
10
  author_email="info@circles.life",
11
11
  url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
File without changes
File without changes