This document provides documentation for various functions used in the Django project. Each section outlines the purpose and functionality of a specific function.
Retrieves all items from the Items model.
def getItems():
"""
Retrieves all items from the Items model.
Returns:
- QuerySet: A queryset containing all items in the Items model.
"""
Retrieves all ingredients from the Ingredients model.
def getIngredients():
"""
Retrieves all ingredients from the Ingredients model.
Returns:
- QuerySet: A queryset containing all ingredients in the Ingredients model.
"""
Retrieves all ingredient items associated with a specific item.
def getIngredientItems(item_id):
"""
Retrieves all ingredient items associated with a specific item.
Parameters:
- item_id (int): The ID of the item for which to retrieve associated ingredient items.
Returns:
- QuerySet: A queryset containing all ingredient items associated with the specified item.
"""
Retrieves recent orders of a user with details about the items included in each order.
def getUserOrders(user_id):
"""
Retrieves recent orders of a user with details about the items included in each order.
Parameters:
- user_id (int): The ID of the user for whom to retrieve recent orders.
Returns:
- dict: A dictionary where keys are order IDs, and values are dictionaries containing order details.
Each order detail includes information about the order and a list of items included in the order.
"""
Retrieves a specified number of undelivered orders along with details about the items included in each order.
def getMobileOrders():
"""
Retrieves a specified number of undelivered orders along with details about the items included in each order.
Returns:
- dict: A dictionary where keys are order IDs, and values are dictionaries containing order details.
Each order detail includes information about the order and a list of items included in the order.
"""
Retrieves order details within a specified range, including information about the items in each order.
def getOrders(start=models.Orders.get_next_highest_id()):
"""
Retrieves order details within a specified range, including information about the items in each order.
Parameters:
- start (int): The starting order ID for the range. Defaults to the next highest order ID.
Returns:
- dict: A dictionary where keys are order IDs, and values are dictionaries containing order details.
Each order detail includes information about the order and a list of common names of items included in the order.
"""
Retrieves a specific order by its ID.
def getOrder(id_num):
"""
Retrieves a specific order by its ID.
Parameters:
- id_num (int): The ID of the order to retrieve.
Returns:
- models.Orders or None: The order object if found, or None if the order with the given ID does not exist.
"""
Retrieves a specific item by its ID.
def getItem(id_num):
"""
Retrieves a specific item by its ID.
Parameters:
- id_num (int): The ID of the item to retrieve.
Returns:
- models.Items or None: The item object if found, or None if the item with the given ID does not exist.
"""
Retrieves order items for a list of orders.
def getOrderItems(orders):
"""
Retrieves order items for a list of orders.
Parameters:
- orders (list): List of order objects.
Returns:
- dict: A dictionary containing a list of order items for each order in the input list.
The structure is {'orders': [order_items_list1, order_items_list2, ...]}.
"""
Generates a sales graph for a given item based on its item_id.
def salesGraph(item_id=0):
"""
Generates a sales graph for a given item based on its item_id.
Parameters:
- item_id (int, optional): The ID of the item for which sales data should be plotted. Default is 0.
Returns:
- plotly.graph_objects.Figure: A Plotly Figure object representing the sales graph.
"""
Generates a stock graph for a given ingredient based on its ingredient_id.
def stockGraph(ingredient_id=0):
"""
Generates a stock graph for a given ingredient based on its ingredient_id.
Parameters:
- ingredient_id (int, optional): The ID of the ingredient for which stock data should be plotted. Default is 0.
Returns:
- plotly.graph_objects.Figure: A Plotly Figure object representing the stock graph.
"""
Retrieves a queryset of ingredients that have stock levels below or equal to 20.
def get_restock_alerts():
"""
Retrieves a queryset of ingredients that have stock levels below or equal to 20.
Returns:
- QuerySet: A Django QuerySet containing ingredient details (id, common_name, stock) for ingredients that require restocking.
"""
Retrieves a list of ingredients that have a low sales percentage compared to their total inventory within a specified time range.
def get_excess_alerts(time, endTime):
"""
Retrieves a list of ingredients that have a low sales percentage compared to their total inventory
within a specified time range.
Args:
- time (datetime): Start of the time range.
- endTime (datetime): End of the time range.
Returns:
- List: A list of dictionaries containing ingredient details (id, common_name, amount_sold, total_inventory) for ingredients with low sales percentages.
"""
Retrieves a list of the top common item pairs based on their co-occurrence in orders.
def get_top_common_items():
"""
Retrieves a list of the top common item pairs based on their co-occurrence in orders.
Returns:
- List: A list of strings representing common item pairs and their occurrence counts, ordered by occurrence in descending order.
"""