File size: 2,810 Bytes
efda44d 9a33c82 efda44d | 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 | <?php
declare(strict_types=1);
class DashboardController
{
public function index(): void
{
$db = Database::getInstance();
// Collection summary
$collectionSummary = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'collection_summary'");
if (!empty($row[0]['value'])) {
$collectionSummary = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Topic profiles
$topicProfiles = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'topic_profiles'");
if (!empty($row[0]['value'])) {
$topicProfiles = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Collection similarity
$similarities = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'collection_similarity'");
if (!empty($row[0]['value'])) {
$similarities = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Bridge entities (PERSON)
$bridgePersons = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'bridge_entities_person'");
if (!empty($row[0]['value'])) {
$bridgePersons = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Bridge entities (ORG)
$bridgeOrgs = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'bridge_entities_org'");
if (!empty($row[0]['value'])) {
$bridgeOrgs = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Sentiment summary
$sentimentSummary = [];
try {
$row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'sentiment_summary'");
if (!empty($row[0]['value'])) {
$sentimentSummary = json_decode($row[0]['value'], true) ?: [];
}
} catch (\PDOException $e) {}
// Stamp distribution
$stamps = [];
try {
$stamps = $db->fetchAll("
SELECT stamp->>'stamp' as classification, COUNT(*) as doc_count
FROM document_features,
jsonb_array_elements(feature_json->'stamps') as stamp
WHERE feature_name = 'forensic_metadata'
GROUP BY stamp->>'stamp'
ORDER BY doc_count DESC
");
} catch (\PDOException $e) {}
require __DIR__ . '/../views/dashboard.php';
}
}
|