Skip to content

Commit

Permalink
Lets add a bit more data
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Nov 25, 2024
1 parent 8c66ee6 commit 9e51dba
Show file tree
Hide file tree
Showing 5 changed files with 959 additions and 3 deletions.
2 changes: 2 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
['name' => 'registers#upload', 'url' => '/api/registers/upload', 'verb' => 'POST'],
['name' => 'registers#uploadUpdate', 'url' => '/api/registers/{id}/upload', 'verb' => 'PUT', 'requirements' => ['id' => '[^/]+']],
['name' => 'registers#download', 'url' => '/api/registers/{id}/download', 'verb' => 'GET', 'requirements' => ['id' => '[^/]+']],
['name' => 'dashboard#qualityStats', 'url' => '/api/dashboard/quality-stats', 'verb' => 'GET'],
['name' => 'dashboard#schemaAnalysis', 'url' => '/api/dashboard/schema-analysis', 'verb' => 'GET'],
],
];
65 changes: 65 additions & 0 deletions lib/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,69 @@ public function growthStats(?string $from = null, ?string $to = null): JSONRespo
return new JSONResponse(['error' => $e->getMessage()], 500);
}
}

/**
* Get data quality statistics
*
* @NoAdminRequired
* @NoCSRFRequired
* @param string|null $from Start date
* @param string|null $to End date
* @return JSONResponse Data quality statistics
*/
public function qualityStats(?string $from = null, ?string $to = null): JSONResponse {
try {
$fromDate = $from ? new \DateTime($from) : new \DateTime('-7 days');
$toDate = $to ? new \DateTime($to) : new \DateTime();

$validationErrors = $this->objectMapper->getValidationStats($fromDate, $toDate);
$completeness = $this->objectMapper->getCompletenessStats($fromDate, $toDate);
$revisions = $this->objectMapper->getRevisionStats($fromDate, $toDate);

$response = [
'validationErrors' => $validationErrors,
'completeness' => $completeness,
'revisions' => $revisions,
];

// Debug log
error_log('Quality Stats Response: ' . json_encode($response));

return new JSONResponse($response);
} catch (\Exception $e) {
error_log('Quality Stats Error: ' . $e->getMessage());
return new JSONResponse(['error' => $e->getMessage()], 500);
}
}

/**
* Get schema analysis statistics
*
* @NoAdminRequired
* @NoCSRFRequired
* @return JSONResponse Schema analysis statistics
*/
public function schemaAnalysis(): JSONResponse {
try {
$fieldTypes = $this->schemaMapper->getFieldTypeStats();
$fieldUsage = $this->schemaMapper->getFieldUsageStats();
$schemaComplexity = $this->schemaMapper->getComplexityStats();
$versionDistribution = $this->schemaMapper->getVersionDistribution();

$response = [
'fieldTypes' => $fieldTypes,
'fieldUsage' => $fieldUsage,
'complexity' => $schemaComplexity,
'versions' => $versionDistribution,
];

// Debug log
error_log('Schema Analysis Response: ' . json_encode($response));

return new JSONResponse($response);
} catch (\Exception $e) {
error_log('Schema Analysis Error: ' . $e->getMessage());
return new JSONResponse(['error' => $e->getMessage()], 500);
}
}
}
Loading

0 comments on commit 9e51dba

Please sign in to comment.