Skip to content
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

Buy and Sell Backend - 1 #12

Open
DikshantK2004 opened this issue Aug 6, 2024 · 0 comments
Open

Buy and Sell Backend - 1 #12

DikshantK2004 opened this issue Aug 6, 2024 · 0 comments
Labels
enhancement New feature or request python

Comments

@DikshantK2004
Copy link
Collaborator

DikshantK2004 commented Aug 6, 2024

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

  1. Update tables.sql file:

    • Add new tables for buy and sell functionalities.
  2. 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.

@DikshantK2004 DikshantK2004 added enhancement New feature or request python labels Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python
Projects
None yet
Development

No branches or pull requests

1 participant