-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_statistics.php
More file actions
84 lines (71 loc) · 2.96 KB
/
Copy pathfetch_statistics.php
File metadata and controls
84 lines (71 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once __DIR__ . '/SolidJobsClient.php';
function printBand(?array $band): void
{
if ($band === null) {
echo " (no offers with a declared salary)\n";
return;
}
echo " min={$band['min']} p25={$band['p25']} median={$band['median']} p75={$band['p75']} max={$band['max']}\n";
}
function printContractSalary(string $label, ?array $stat): void
{
if ($stat === null) {
echo " $label: (no precomputed data)\n";
return;
}
echo " $label: median={$stat['median']} average={$stat['average']} offers={$stat['offerCount']}\n";
}
function printBuckets(array $buckets): void
{
foreach ($buckets as $b) {
printf(" %-24s %5d offers (%d%%)\n", $b['label'], $b['offerCount'], $b['percentage']);
}
}
function printStatistics(array $stats): void
{
echo "Scope: {$stats['scopeKind']} / {$stats['scopeKey']}\n";
echo "Generated at: {$stats['generatedAt']}\n";
echo 'Included sections: ' . implode(', ', $stats['includedSections']) . "\n";
if (isset($stats['demand'])) {
$d = $stats['demand'];
echo "\n[demand]\n";
echo " activeOffers={$d['activeOffers']} distinctEmployers={$d['distinctEmployers']}"
. " remoteOffers={$d['remoteOffers']} remotePercentage={$d['remotePercentage']}%\n";
echo " offerTrend (quarterly):\n";
foreach ($d['offerTrend'] as $point) {
echo " {$point['period']}: {$point['offerCount']} offers\n";
}
}
if (isset($stats['salary'])) {
$s = $stats['salary'];
echo "\n[salary] currency={$s['currency']}\n";
echo " overall (live percentiles):\n";
printBand($s['overall'] ?? null);
printContractSalary('b2b ', $s['b2b'] ?? null);
printContractSalary('permanent ', $s['permanent'] ?? null);
}
if (isset($stats['experience'])) {
echo "\n[experience]\n";
printBuckets($stats['experience']);
}
if (isset($stats['topLocations'])) {
echo "\n[topLocations]\n";
printBuckets($stats['topLocations']);
}
if (isset($stats['topSkills'])) {
echo "\n[topSkills]\n";
printBuckets($stats['topSkills']);
}
}
$client = new SolidJobsClient();
$campaign = 'php-stats';
// 1) Full snapshot — every section available for the React specialization
$full = $client->getMarketStatistics('subcategory', 'React', $campaign);
printStatistics($full);
// 2) Partial fetch — ask only for `demand` and `salary` using the `fields` filter.
// `includedSections` in the response confirms exactly what came back.
echo "\n───────────────────────────────────────────────\n";
echo "Partial fetch with fields=demand,salary:\n";
$partial = $client->getMarketStatistics('subcategory', 'React', $campaign, ['demand', 'salary']);
echo 'Included sections: ' . implode(', ', $partial['includedSections']) . "\n";