Supplier Functions
Documentation for Supplier Management Functions
Overview
This collection of functions provides a variety of operations related to managing supplier information within a Firebase Firestore database. These operations include fetching supplier details, updating supplier information, and managing specific fields related to supplier activities and statuses.
Function Descriptions
-
get_supplier_by_user_id(user_id)- Retrieves a supplier’s profile information based on the user ID.
- Parameters:
user_id: The unique identifier of the user.
- Returns:
- The supplier’s profile information as a dictionary if found; otherwise,
None.
- The supplier’s profile information as a dictionary if found; otherwise,
-
update_supplier_pan_token(user_id, pan_token)- Updates the PAN token for a specific supplier.
- Parameters:
user_id: The document ID in thesupplierprofileinformationcollection.pan_token: The new PAN token to be stored.
-
update_supplier_tier(user_id, tier)- Updates the subscription tier of a supplier.
- Parameters:
user_id: The document ID.tier: The new tier to assign to the supplier.
-
update_supplier_search_count(user_id, new_count)- Updates the count of semantic searches performed by a supplier.
- Parameters:
user_id: The supplier’s user ID.new_count: The new count of semantic searches.
-
get_free_suppliers()- Fetches a list of suppliers who are on a free subscription tier.
- Returns:
- A list of dictionaries, each representing a supplier on the free tier.
-
get_paid_suppliers()- Retrieves a list of suppliers on paid or complementary subscription tiers.
- Returns:
- A list of dictionaries, each representing a supplier on a paid or complementary tier.
-
update_supplier_proposals_generated_count(user_id, new_count)- Updates the number of proposals generated by a supplier.
- Parameters:
user_id: The supplier’s user ID.new_count: The new count to update.
-
add_proposals_generated_field()- Adds a
numberOfProposalsGeneratedfield to all supplier documents, initialized to 0. - Useful for setting up new database fields or ensuring data consistency across documents.
- Adds a
-
add_clicked_apply_for_the_month_field()- Adds a field to track monthly clicks on the “apply” button by suppliers.
- Initializes this count to 0 for all suppliers.
-
get_all_suppliers()- Retrieves a list of all suppliers in the database.
- Returns:
- A list of all suppliers as dictionaries.
-
reset_supplier_applyBtnClickedForTheMonth_count(user_id)- Resets the monthly “apply” button click count for a specific supplier.
- Parameters:
user_id: The supplier’s user ID.
-
add_total_engagement_score_field()- Adds a
totalEngagementScorefield with a value of 0 to all supplier documents. - Useful for tracking engagement scores across supplier profiles.
- Adds a
-
reset_all_engagement_scores()- Resets the
totalEngagementScoreto 0 for all suppliers in the database.
- Resets the
-
calculate_average_engagement_score()- Calculates the average engagement score across all suppliers.
- Returns:
- The average engagement score if there are suppliers; otherwise, an informative message is printed if no suppliers are found.
Usage Example
# Update a supplier's tieruser_id = 'some_user_id'new_tier = 'premium'update_supplier_tier(user_id, new_tier)
# Fetch all suppliers on a free tierfree_suppliers = get_free_suppliers()print(free_suppliers)
# Calculate and print the average engagement scoreaverage_score = calculate_average_engagement_score()print(f"Average Engagement Score: {average_score}")These functions are integral for managing supplier-related data within applications that utilize Firebase Firestore for data management, ensuring that supplier interactions and statuses are accurately tracked and updated.