Add database adapter system, production deployment configs, and new dashboard components
- Add PostgreSQL and SQLite database adapters with factory pattern - Add migration script for SQLite to PostgreSQL - Add production Dockerfiles and docker-compose configs - Add deployment documentation and scripts - Add BIA sync dashboard and matching service - Add data completeness configuration and components - Add new dashboard components (BusinessImportanceComparison, ComplexityDynamics, etc.) - Update various services and routes - Remove deprecated management-parameters.json and taxonomy files
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { Router } from 'express';
|
||||
import { OBJECT_TYPES, SCHEMA_GENERATED_AT, SCHEMA_OBJECT_TYPE_COUNT, SCHEMA_TOTAL_ATTRIBUTES } from '../generated/jira-schema.js';
|
||||
import type { ObjectTypeDefinition, AttributeDefinition } from '../generated/jira-schema.js';
|
||||
import { dataService } from '../services/dataService.js';
|
||||
import { logger } from '../services/logger.js';
|
||||
import { jiraAssetsClient } from '../services/jiraAssetsClient.js';
|
||||
import type { CMDBObjectTypeName } from '../generated/jira-types.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -27,13 +31,15 @@ interface SchemaResponse {
|
||||
totalAttributes: number;
|
||||
};
|
||||
objectTypes: Record<string, ObjectTypeWithLinks>;
|
||||
cacheCounts?: Record<string, number>; // Cache counts by type name (from objectsByType)
|
||||
jiraCounts?: Record<string, number>; // Actual counts from Jira Assets API
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/schema
|
||||
* Returns the complete Jira Assets schema with object types, attributes, and links
|
||||
*/
|
||||
router.get('/', (req, res) => {
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
// Build links between object types
|
||||
const objectTypesWithLinks: Record<string, ObjectTypeWithLinks> = {};
|
||||
@@ -72,6 +78,41 @@ router.get('/', (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Get cache counts (objectsByType) if available
|
||||
let cacheCounts: Record<string, number> | undefined;
|
||||
try {
|
||||
const cacheStatus = await dataService.getCacheStatus();
|
||||
cacheCounts = cacheStatus.objectsByType;
|
||||
} catch (err) {
|
||||
logger.debug('Could not fetch cache counts for schema response', err);
|
||||
// Continue without cache counts - not critical
|
||||
}
|
||||
|
||||
// Fetch actual counts from Jira Assets for all object types
|
||||
// This ensures the counts match exactly what's in Jira Assets
|
||||
const jiraCounts: Record<string, number> = {};
|
||||
const typeNames = Object.keys(OBJECT_TYPES) as CMDBObjectTypeName[];
|
||||
|
||||
logger.info(`Schema: Fetching object counts from Jira Assets for ${typeNames.length} object types...`);
|
||||
|
||||
// Fetch counts in parallel for better performance
|
||||
const countPromises = typeNames.map(async (typeName) => {
|
||||
try {
|
||||
const count = await jiraAssetsClient.getObjectCount(typeName);
|
||||
jiraCounts[typeName] = count;
|
||||
return { typeName, count };
|
||||
} catch (error) {
|
||||
logger.warn(`Schema: Failed to get count for ${typeName}`, error);
|
||||
// Use 0 as fallback if API call fails
|
||||
jiraCounts[typeName] = 0;
|
||||
return { typeName, count: 0 };
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(countPromises);
|
||||
|
||||
logger.info(`Schema: Fetched counts for ${Object.keys(jiraCounts).length} object types from Jira Assets`);
|
||||
|
||||
const response: SchemaResponse = {
|
||||
metadata: {
|
||||
generatedAt: SCHEMA_GENERATED_AT,
|
||||
@@ -79,6 +120,8 @@ router.get('/', (req, res) => {
|
||||
totalAttributes: SCHEMA_TOTAL_ATTRIBUTES,
|
||||
},
|
||||
objectTypes: objectTypesWithLinks,
|
||||
cacheCounts,
|
||||
jiraCounts,
|
||||
};
|
||||
|
||||
res.json(response);
|
||||
|
||||
Reference in New Issue
Block a user