get_strategic_clients_list
Retrieves a strategic list of clients with aggregated analytics and metrics.
Signature
get_strategic_clients_list ( $filters = [], $limit = null , $offset = 0 )
Parameters
Associative array of filter criteria: Search term for client name
Exact client name to filter
Filter by session start date (YYYY-MM-DD format)
Filter by session end date (YYYY-MM-DD format)
Sort order: ‘name_asc’, ‘name_desc’, ‘date_asc’, ‘date_desc’, ‘areas_desc’, ‘games_desc’, ‘users_desc’, ‘performance_desc’, ‘risk_desc’
Maximum number of results. If null, returns all matching clients.
Number of results to skip for pagination.
Returns
Array of client objects with strategic metrics: Show Client object properties
Client creation timestamp
Industry classification (currently ‘N/A’)
Market segment (currently ‘N/A’)
Number of distinct areas associated with this client
Number of games (dilemmas) associated with this client
Number of unique users who have played client games
Total invited users (currently 0 as per schema)
Percentage of sessions completed (0-100, rounded to 1 decimal)
Average score across all sessions (rounded to 1 decimal)
Percentage of users with scores below 60 (0-100, rounded to 1 decimal)
Example Usage
Basic usage
With search
Sorted by performance
High-risk clients
Date range with pagination
// Get all clients
$clients = get_strategic_clients_list ();
foreach ( $clients as $client ) {
echo $client [ 'name' ] . ' - ' . $client [ 'games_count' ] . ' games' ;
}
Implementation Details
This function performs complex aggregation across multiple tables including de_posts, de_postmeta, and de_app_sessions to calculate strategic metrics.
When date filters are applied, the query switches to filter clients based on session dates rather than client creation dates. This ensures you see clients with activity in the specified period.
Sort Options
Value Description name_ascClient name A-Z name_descClient name Z-A date_ascOldest first date_descNewest first areas_descMost areas first games_descMost games first users_descMost active users first performance_descBest performance first risk_descHighest risk first
get_clients
Retrieves basic client information with pagination and sorting.
Signature
get_clients ( $search = null , $sort = 'name' , $order = 'ASC' , $limit = 10 , $offset = 0 )
Parameters
Search term for client name
Sort field: ‘name’ or ‘createdAt’
Sort order: ‘ASC’ or ‘DESC’
Maximum number of results
Number of results to skip
Returns
Array of client objects with basic info and counts
Example Usage
// Get first page of clients sorted by name
$clients = get_clients ( null , 'name' , 'ASC' , 20 , 0 );
// Search clients and sort by creation date
$clients = get_clients ( 'tech' , 'createdAt' , 'DESC' , 10 , 0 );
get_clients_count
Returns the total count of clients matching search criteria.
Signature
get_clients_count ( $search = null )
Parameters
Optional search term for client name
Returns
Total number of clients matching the search
Example Usage
$totalClients = get_clients_count ();
echo "Total clients: " . $totalClients ;
$matchingClients = get_clients_count ( 'acme' );
echo "Matching clients: " . $matchingClients ;
get_client_by_name
Retrieves a client record by exact name match.
Signature
get_client_by_name ( $name )
Parameters
Exact client name to search for
Returns
Client object with id, name, and logo, or false if not found
Example Usage
$client = get_client_by_name ( 'Acme Corporation' );
if ( $client ) {
echo "Client ID: " . $client [ 'id' ];
echo "Logo: " . $client [ 'logo' ];
}
get_strategic_client_detail
Retrieves comprehensive details and metrics for a specific client.
Signature
get_strategic_client_detail ( $clientId )
Parameters
Returns
Detailed client object with all strategic metrics, or null if not found: Show Client detail properties
Total users in client’s areas
Completion rate percentage
Average correctness score
Participation rate percentage
Composite engagement score
Example Usage
$client = get_strategic_client_detail ( 42 );
if ( $client ) {
echo "Client: " . $client [ 'name' ];
echo "Areas: " . $client [ 'areas_count' ];
echo "Active Users: " . $client [ 'active_users' ];
echo "Engagement Score: " . $client [ 'engagement_score' ];
echo "Risk Index: " . $client [ 'risk_index' ] . '%' ;
}
This function uses caching with a 600-second TTL to improve performance. Results are cached by client ID.
get_client_strategic_funnel
Retrieves funnel metrics for a client showing user progression.
Signature
get_client_strategic_funnel ( $clientId )
Parameters
Returns
Array of funnel stage objects: Stage label (‘Iniciados’, ‘Finalizados’, ‘Aprobados’)
Number of users at this stage
Example Usage
$funnel = get_client_strategic_funnel ( 42 );
foreach ( $funnel as $stage ) {
echo $stage [ 'label' ] . ': ' . $stage [ 'value' ] . ' users' ;
}
// Calculate conversion rates
$started = $funnel [ 0 ][ 'value' ];
$finished = $funnel [ 1 ][ 'value' ];
$approved = $funnel [ 2 ][ 'value' ];
$completionRate = $started > 0 ? round (( $finished / $started ) * 100 , 1 ) : 0 ;
$approvalRate = $finished > 0 ? round (( $approved / $finished ) * 100 , 1 ) : 0 ;
echo "Completion Rate: { $completionRate }%" ;
echo "Approval Rate: { $approvalRate }%" ;
get_unique_clients
Retrieves a list of unique client names for dropdown/filter purposes.
Signature
Returns
Array of client names (strings)
Example Usage
$clients = get_unique_clients ();
echo '<select name="client">' ;
foreach ( $clients as $clientName ) {
echo '<option value="' . htmlspecialchars ( $clientName ) . '">' .
htmlspecialchars ( $clientName ) . '</option>' ;
}
echo '</select>' ;
Games Client game management
Users Client user management