-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lost and found refactor #13
Conversation
FOUND = found_images_table | ||
|
||
|
||
def insert_in_table(TableType, form_data: Dict[str, Any], user_id: int ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here declare TableType like.
def insert_in_table(table_type: TableType,........)
Make relevant changes at other places too.
@@ -22,7 +22,7 @@ async def add_item( request: Request, | |||
form_data_dict = json.loads(form_data) | |||
user_id = get_user_id(request) | |||
with conn.cursor() as cur: | |||
cur.execute( insert_in_lost_table( form_data_dict, user_id ) ) | |||
cur.execute( insert_in_table(0, form_data_dict, user_id ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were supposed to pass a TableType.LOST
or TableType.FOUND
, but you have passed integers, and it gives errors. Fix this error in all the files.
class TableImagesType(Enum): | ||
LOST = lost_images_table | ||
FOUND = found_images_table | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice that you used enums. For uniformity, could you move these enums to models.py
and make appropriate imports?
Closing this PR now. Kindly make a new PR on the backend branch. |
This change resolves #11 by merging the
queries/lost.py
andqueries/found.py
intoqueries/lost_and_found.py
and changing the implementation in theRoutes/Lost_and_Found/
files.I didn't merge the
Routes/
files because it wasn't specified, but it doesn't look too hard to implement.