Skip to content

Commit 08ed9ce

Browse files
author
Joel Collins
committed
Added Action queue method
1 parent 27d5833 commit 08ed9ce

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/labthings/view/__init__.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,18 @@ class ActionView(View):
135135
_cls_tags = {"actions"}
136136
_deque = Deque() # Action queue
137137

138+
def get(self):
139+
queue_schema = build_action_schema(self.schema, self.args)(many=True)
140+
return queue_schema.dump(self._deque)
141+
138142
@classmethod
139143
def get_apispec(cls):
140144
class_args = schema_to_json(cls.args)
141-
class_action_schema = schema_to_json(
142-
build_action_schema(cls.schema, cls.args)()
143-
)
144-
class_action_queue_schema = schema_to_json(
145+
action_json_schema = schema_to_json(build_action_schema(cls.schema, cls.args)())
146+
queue_json_schema = schema_to_json(
145147
build_action_schema(cls.schema, cls.args)(many=True)
146148
)
147-
class_schema = schema_to_json(cls.schema)
149+
class_json_schema = schema_to_json(cls.schema)
148150
d = {
149151
"post": {
150152
"description": getattr(cls, "description", None) or get_docstring(cls),
@@ -163,9 +165,7 @@ def get_apispec(cls):
163165
"content_type": "application/json",
164166
"description": "Action started",
165167
**(
166-
{"schema": class_action_schema}
167-
if class_action_schema
168-
else {}
168+
{"schema": action_json_schema} if action_json_schema else {}
169169
),
170170
}
171171
},
@@ -179,11 +179,7 @@ def get_apispec(cls):
179179
200: {
180180
"content_type": "application/json",
181181
"description": "Action started",
182-
**(
183-
{"schema": class_action_queue_schema}
184-
if class_action_queue_schema
185-
else {}
186-
),
182+
**({"schema": queue_json_schema} if queue_json_schema else {}),
187183
}
188184
},
189185
},

0 commit comments

Comments
 (0)