Skip to main content

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

filters
array
default:"[]"
Associative array of filter criteria:
limit
integer
default:"null"
Maximum number of results. If null, returns all matching clients.
offset
integer
default:"0"
Number of results to skip for pagination.

Returns

clients
array
Array of client objects with strategic metrics:

Example Usage

// 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

ValueDescription
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
string
default:"null"
Search term for client name
sort
string
default:"'name'"
Sort field: ‘name’ or ‘createdAt’
order
string
default:"'ASC'"
Sort order: ‘ASC’ or ‘DESC’
limit
integer
default:"10"
Maximum number of results
offset
integer
default:"0"
Number of results to skip

Returns

clients
array
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

search
string
default:"null"
Optional search term for client name

Returns

count
integer
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

name
string
required
Exact client name to search for

Returns

client
object
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

clientId
integer
required
Client ID

Returns

client
object
Detailed client object with all strategic metrics, or null if not found:

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

clientId
integer
required
Client ID

Returns

funnel
array
Array of funnel stage objects:

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

get_unique_clients()

Returns

clients
array
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

Build docs developers (and LLMs) love