datamatters24 commited on
Commit
efda44d
·
verified ·
1 Parent(s): 303e71a

Upload web/src/controllers/DashboardController.php with huggingface_hub

Browse files
web/src/controllers/DashboardController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ declare(strict_types=1);
4
+
5
+ class DashboardController
6
+ {
7
+ public function index(): void
8
+ {
9
+ $db = Database::getInstance();
10
+
11
+ // Collection summary
12
+ $collectionSummary = [];
13
+ try {
14
+ $row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'collection_summary'");
15
+ if (!empty($row[0]['value'])) {
16
+ $collectionSummary = json_decode($row[0]['value'], true) ?: [];
17
+ }
18
+ } catch (\PDOException $e) {}
19
+
20
+ // Topic profiles
21
+ $topicProfiles = [];
22
+ try {
23
+ $row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'topic_profiles'");
24
+ if (!empty($row[0]['value'])) {
25
+ $topicProfiles = json_decode($row[0]['value'], true) ?: [];
26
+ }
27
+ } catch (\PDOException $e) {}
28
+
29
+ // Collection similarity
30
+ $similarities = [];
31
+ try {
32
+ $row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'collection_similarity'");
33
+ if (!empty($row[0]['value'])) {
34
+ $similarities = json_decode($row[0]['value'], true) ?: [];
35
+ }
36
+ } catch (\PDOException $e) {}
37
+
38
+ // Bridge entities (PERSON)
39
+ $bridgePersons = [];
40
+ try {
41
+ $row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'bridge_entities_person'");
42
+ if (!empty($row[0]['value'])) {
43
+ $bridgePersons = json_decode($row[0]['value'], true) ?: [];
44
+ }
45
+ } catch (\PDOException $e) {}
46
+
47
+ // Bridge entities (ORG)
48
+ $bridgeOrgs = [];
49
+ try {
50
+ $row = $db->fetchAll("SELECT value FROM analytics_cache WHERE key = 'bridge_entities_org'");
51
+ if (!empty($row[0]['value'])) {
52
+ $bridgeOrgs = json_decode($row[0]['value'], true) ?: [];
53
+ }
54
+ } catch (\PDOException $e) {}
55
+
56
+ // Stamp distribution
57
+ $stamps = [];
58
+ try {
59
+ $stamps = $db->fetchAll("
60
+ SELECT stamp->>'stamp' as classification, COUNT(*) as doc_count
61
+ FROM document_features,
62
+ jsonb_array_elements(feature_json->'stamps') as stamp
63
+ WHERE feature_name = 'forensic_metadata'
64
+ GROUP BY stamp->>'stamp'
65
+ ORDER BY doc_count DESC
66
+ ");
67
+ } catch (\PDOException $e) {}
68
+
69
+ require __DIR__ . '/../views/dashboard.php';
70
+ }
71
+ }