You need to buy and sell backend from scratch. jk. Buy and Sell backend will be very similar to Lost and Found. (Find the similarities).
Task Overview
In this task, you need to update the tables.sql file with new required tables and create /backend/backend/buy_sell.py which will contain pypika queries for the backend. You need to copy the queries from lost.py and rename functions, table names, and also have a type parameter to be able to distinguish between buy and sell tables.
Tasks
-
Update tables.sql file:
- Add new tables for buy and sell functionalities.
-
Create a new file: /backend/backend/buy_sell.py.
- Copy the queries from
lost.py.
- Rename the functions and table names to correspond to buy and sell operations.
- Add a new parameter
type to each function to distinguish between buy and sell tables(and their corresponding image tables).
Type Parameter
The type parameter should be:
0 for queries on the buy table.
1 for queries on the sell table.
Example
Before (in lost.py):
def get_lost_items():
def insert_in_lost_table( form_data: Dict[str, Any], user_id: int ):
query = Query.into(lost_table).columns('item_name', 'item_description', 'user_id').insert(
form_data['item_name'], form_data['item_description'], user_id
)
...
return sql_query
After (in buy_sell.py):
def insert_in_table( form_data: Dict[str, Any], user_id: int, type:int ):
table = (type == 0? sell_table: buy_table)
query = Query.into(table).columns('item_name', 'item_description', 'user_id').insert(
form_data['item_name'], form_data['item_description'], user_id
)
...
return sql_query
Note: Pull requests (PRs) on branches other than backend will be closed.
You need to buy and sell backend from scratch. jk. Buy and Sell backend will be very similar to Lost and Found. (Find the similarities).
Task Overview
In this task, you need to update the
tables.sqlfile with new required tables and create/backend/backend/buy_sell.pywhich will contain pypika queries for the backend. You need to copy the queries fromlost.pyand rename functions, table names, and also have atypeparameter to be able to distinguish between buy and sell tables.Tasks
Update
tables.sqlfile:Create a new file:
/backend/backend/buy_sell.py.lost.py.typeto each function to distinguish between buy and sell tables(and their corresponding image tables).Type Parameter
The
typeparameter should be:0for queries on the buy table.1for queries on the sell table.Example
Before (in
lost.py):After (in
buy_sell.py):Note: Pull requests (PRs) on branches other than backend will be closed.