Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grouple.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Grouple has 40+ PostgreSQL functions. They fall into four categories: trigger functions (called by triggers), security/RLS helpers (used in RLS policies), business logic functions (called via supabase.rpc()), and analytics functions.

Trigger Functions

These are called exclusively by database triggers:
FunctionCalled ByPurpose
auto_sync_proposal_statusTriggerSyncs proposal status automatically
broadcast_enquiry_to_venueson_enquiry_created_broadcastMatches and creates venue_leads for a new enquiry
check_menu_pdf_limittr_check_menu_pdf_limitEnforces PDF upload limit per subscription plan
check_venue_limittr_check_venue_limitEnforces venue creation limit per plan
fn_record_response_timetrg_record_response_timeRecords merchant response time to lead_response_times
fn_set_venue_lead_timestampstrg_set_venue_lead_timestampsSets status timestamp fields on venue_leads
handle_proposal_confirmationTriggerHandles proposal confirmation side effects
link_customer_to_enquirieson_customer_created_link_enquiriesLinks pre-existing enquiries to new customer
set_merchant_rfq_numberbefore_insert_venue_leads_set_rfq_numberAssigns sequential RFQ number per merchant
sync_confirmed_proposal_to_settlementstrigger_sync_settlementCreates commission_settlements on confirmation
sync_enquiry_currencytr_sync_enquiry_currencySets enquiry currency from city default
sync_only_proposal_on_confirmationTriggerSyncs proposal data on confirmation
sync_venue_currency_from_merchanttrigger_sync_venue_currencySyncs venue currency when merchant currency changes
update_modified_columnTriggerUpdates updated_at timestamp

Security / RLS Helper Functions

Used inside RLS policies to keep them readable:
FunctionReturnsPurpose
check_can_view_merchant(merchant_id)booleanCan current user view this merchant?
check_can_view_venue(venue_id)booleanCan current user view this venue?
check_is_enquiry_customer(enquiry_id)booleanIs current user the customer of this enquiry?
check_is_lead_merchant(venue_lead_id)booleanIs current user the merchant of this lead?
is_merchant_owner(merchant_id)booleanIs current user this merchant?
is_proposal_customer(proposal_id)booleanIs current user the customer for this proposal?
is_proposal_merchant(proposal_id)booleanIs current user the merchant for this proposal?
is_venue_owner(venue_id)booleanIs current user the owner of this venue?

Business Logic Functions (called via supabase.rpc())

FunctionReturnsPurpose
check_availability(...)booleanChecks if a venue is available for given date/time
confirm_single_booking(...)voidConfirms a single booking
create_booking_if_available(...)recordCreates a booking if the venue is available
customer_proposals_rpc(...)jsonbReturns all proposals for a customer’s enquiries
fn_get_or_create_amenity(name)uuidGets or creates an amenity record
fn_get_or_create_cuisine(name)uuidGets or creates a cuisine record
fn_match_venues_for_enquiry(enquiry_id)uuidReturns matched venue IDs for an enquiry
get_merchant_proposal_by_id_or_token(...)jsonbFetches a proposal by ID or public token
get_proposal_by_any_id(...)recordFetches a proposal by any identifier
mark_proposal_viewed(proposal_id)voidMarks a proposal as viewed by customer

Analytics Functions (called via supabase.rpc())

FunctionReturnsPurpose
get_avg_group_size(merchant_id)numericAverage group size across merchant’s leads
get_budget_tiers(merchant_id)textBudget tier distribution for merchant
get_enum_values(enum_name)arrayReturns all values for a given enum type
get_lead_distribution(merchant_id)recordLead count by category
get_merchant_ai_usage(merchant_id)recordAI proposal usage stats
get_most_popular_budget_tier(merchant_id)textMost common budget tier
get_most_popular_lead_category(merchant_id)textMost common event category
get_top_category_metrics(merchant_id)recordTop performing category stats