Skip to content

Commit 1ff2486

Browse files
committed
make requested changes
1 parent 2fa2963 commit 1ff2486

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

backend/api/endpoints/command.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ def create_command(payload: CommandRequest, db: Session = Depends(get_db)):
3535
# Find number of commands in database
3636
query = select(Command)
3737
items = db.exec(query).all()
38-
num_commands = len(items)
3938

4039
command = Command (
41-
id=1+num_commands,
4240
command_type=payload.command_type,
4341
params=payload.params,
4442
)
@@ -59,14 +57,13 @@ def delete_command(id: int, db: Session = Depends(get_db)):
5957
@return returns the list of commands after deleting the item
6058
"""
6159
# TODO:(Member) Implement this endpoint
62-
try:
63-
query = select(Command).where(Command.id == id)
64-
command = db.exec(query).one()
60+
command = db.get(Command, id)
61+
if command:
6562
db.delete(command)
6663
db.commit()
6764

6865
query2 = select(Command).where(Command.id != id)
6966
items = db.exec(query2).all()
7067
return {"data": items}
71-
except:
68+
else:
7269
raise HTTPException(status_code=404, detail="Item does not exist")

backend/api/middlewares/logger_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import Request, Response
44
from starlette.middleware.base import BaseHTTPMiddleware
55

6-
from ...utils.logging import logger
6+
from backend.utils.logging import logger
77

88
import time
99
import json

backend/data/data_models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def validate_params_format(self):
3333
The format of the comma seperated values is "data1,data2" so no spaces between data and the commas.
3434
"""
3535
# TODO: (Member) Implement this method
36-
if (self.params == None and self.format == None):
36+
if self.params is None and self.format is None:
3737
return self
38-
elif (self.params == None or self.format == None):
39-
raise(ValueError)
40-
elif (len(self.params.split(",")) == len(self.format.split(","))):
38+
elif self.params is None or self.format is None:
39+
raise ValueError()
40+
elif len(self.params.split(",")) == len(self.format.split(",")):
4141
return self
4242
else:
43-
raise(ValueError)
43+
raise ValueError()
4444

4545
class Command(BaseSQLModel, table=True):
4646
"""
47-
An instance of a MainCommand.
47+
An instance off a MainCommand.
4848
This table holds the data related to actual commands sent from the ground station up to the OBC.
4949
"""
5050

0 commit comments

Comments
 (0)