- Added a new cities table to the database to manage multiple cities independently. - Created a middleware to resolve city context based on X-City-Id header. - Updated routes and services to handle city-specific data for routes, stops, and alerts. - Implemented a CityContext in the frontend to manage active city state and provide city data across the application. - Added a CitySelector component for users to switch between cities. - Created a CitiesPage for admins to manage cities, including adding new cities with validation. - Updated various components and pages to reflect the active city context, ensuring data is displayed correctly based on the selected city. - Enhanced the schedule import functionality to restrict imports based on the active city.
22 lines
740 B
JavaScript
22 lines
740 B
JavaScript
const logger = require('../config/logger');
|
||
const { runQualityChecks } = require('../services/qualityReport');
|
||
|
||
class QualityController {
|
||
constructor({ pool, report = runQualityChecks } = {}) {
|
||
this.pool = pool || require('../config/database');
|
||
this.report = report;
|
||
}
|
||
|
||
async getReport(req, res) {
|
||
try {
|
||
res.json(await this.report(this.pool, req.city.id));
|
||
} catch (error) {
|
||
logger.error('Error building quality report', { message: error.message });
|
||
res.status(500).json({ error: 'Не удалось проверить качество данных. Повторите попытку.' });
|
||
}
|
||
}
|
||
}
|
||
|
||
module.exports = new QualityController();
|
||
module.exports.QualityController = QualityController;
|