Skip to content

Buy and Sell Backend - 1 #12

Description

@DikshantK2004

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions