Skip to content

Commit fda6f11

Browse files
Made fixes according to PR review, updated logger
1 parent 14feae2 commit fda6f11

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

backend/api/endpoints/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def delete_command(id: int, db: Session = Depends(get_db)):
5454
query = select(Command).where(Command.id == id)
5555
result = db.exec(query).first()
5656

57-
if not result:
57+
if result is None:
5858
raise HTTPException(status_code=404, detail=f"Command with id {id} not found.")
5959

6060
db.delete(result)

backend/api/middlewares/logger_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ async def dispatch(
2424
response = await call_next(request)
2525

2626
duration = perf_counter() - start
27-
logger.info
27+
logger.info(f"Response sent in {duration} seconds to Request params: {request.path_params}")
2828
return response

backend/data/data_models.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,13 @@ def validate_params_format(self):
3232
In either of these cases return self. Otherwise raise a ValueError.
3333
The format of the comma seperated values is "data1,data2" so no spaces between data and the commas.
3434
"""
35-
validated_params = self.params
36-
validated_format = self.format
3735

38-
if validated_params == None and validated_format == None:
36+
if self.params is None and self.format is None:
3937
return self
40-
elif isinstance(validated_params, str) and (isinstance(validated_format, str)) and validated_params.count(",") == validated_format.count(","):
38+
elif isinstance(self.params, str) and isinstance(self.format, str) and self.params.count(",", 0, -1) == self.format.count(",", 0, -1):
4139
return self
42-
else:
43-
raise(ValueError
44-
(f"""params and format must both be either None or have the same number of comma seperated values,
45-
recieved:
46-
params: {validated_params}
47-
format: {validated_format}\n"""))
48-
49-
return self
50-
40+
41+
raise ValueError("Params and format either both be None or have the same number of comma separated values.")
5142

5243
class Command(BaseSQLModel, table=True):
5344
"""

frontend/src/display/command_api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export const getCommands = async (): Promise<CommandListResponse> => {
2222
*/
2323
export const deleteCommand = async (id: number): Promise<CommandListResponse> => {
2424
try {
25-
await axios.delete(`${API_URL}/${id}`)
26-
const { data } = await axios.get<CommandListResponse>(`${API_URL}/commands/`)
25+
const { data } = await axios.delete(`${API_URL}/${id}`)
2726
return data;
2827
} catch (error) {
2928
console.error(error)

0 commit comments

Comments
 (0)