Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Mar 4, 2024
2 parents 0ea4d0f + e9d5fe8 commit d4d0a5e
Show file tree
Hide file tree
Showing 133 changed files with 4,502 additions and 2,132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bookkeeping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Copy coverage from container
run: docker cp $(docker ps -aqlf "name=bookkeeping_application"):/usr/src/app/coverage/coverage-final.json .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4

linter:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.79.0](https://github.com/AliceO2Group/Bookkeeping/releases/tag/%40aliceo2%2Fbookkeeping%400.79.0)
* Notable changes for users:
* A log template for on-call has been created
* Improved formatting of on-call logs

## [0.78.1](https://github.com/AliceO2Group/Bookkeeping/releases/tag/%40aliceo2%2Fbookkeeping%400.78.1)
* Notable change for developers:
* All dependencies has been added to the bundle dependencies
Expand Down
17 changes: 9 additions & 8 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const { monalisa: monalisaConfig } = ServicesConfig;
const { handleLostRunsAndEnvironments } = require('./server/services/housekeeping/handleLostRunsAndEnvironments.js');
const { isInTestMode } = require('./utilities/env-utils.js');
const { ScheduledProcessesManager } = require('./server/services/ScheduledProcessesManager.js');
const { MonALISASynchronizer } = require('./server/monalisa-synchronization/MonALISASynchronizer');
const { createMonALISAClient } = require('./server/monalisa-synchronization/MonALISAClient');
const { MonAlisaSynchronizer } = require('./server/monalisa-synchronization/MonAlisaSynchronizer');
const { createMonAlisaClient } = require('./server/monalisa-synchronization/MonAlisaClient');

/**
* Bookkeeping Application
Expand Down Expand Up @@ -56,9 +56,9 @@ class BookkeepingApplication {
}

if (monalisaConfig.enableSynchronization) {
const monALISASynchronizer = await this.createMonALISASynchronizer();
const monAlisaSynchronizer = await this.createMonAlisaSynchronizer();
this.scheduledProcessesManager.schedule(
() => monALISASynchronizer.synchronizeDataPassesFromMonALISA(),
() => monAlisaSynchronizer.synchronize(),
{
wait: 10 * 1000,
every: monalisaConfig.synchronizationPeriod,
Expand All @@ -84,13 +84,14 @@ class BookkeepingApplication {
}

/**
* Instantiate MonALISA synchronizer with global configuration
* @return {MonALISASynchronizer} instance
* Instantiate MonAlisa synchronizer with global configuration
* @return {MonAlisaSynchronizer} instance
*/
async createMonALISASynchronizer() {
return new MonALISASynchronizer(await createMonALISAClient({
async createMonAlisaSynchronizer() {
return new MonAlisaSynchronizer(await createMonAlisaClient({
dataPassesUrl: monalisaConfig.dataPassesUrl,
dataPassDetailsUrl: monalisaConfig.dataPassDetailsUrl,
simulationPassesUrl: monalisaConfig.simulationPassesUrl,
yearLowerLimit: monalisaConfig.dataPassesYearLowerLimit,
userCertificatePath: monalisaConfig.userCertificate.path,
certificatePassphrase: monalisaConfig.userCertificate.passphrase,
Expand Down
3 changes: 3 additions & 0 deletions lib/config/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
DATA_PASSES_YEAR_LOWER_LIMIT,
MONALISA_DATA_PASSES_URL,
MONALISA_DATA_PASS_DETAILS_URL,
MONALISA_SIMULATION_PASSES_URL,
MONALISA_ENABLE_SYNCHRONIZATION,
MONALISA_SYNCHRONIZATION_PERIODS,
} = process.env ?? {};
Expand Down Expand Up @@ -49,6 +50,8 @@ exports.services = {
dataPassesUrl: MONALISA_DATA_PASSES_URL,
dataPassDetailsUrl: MONALISA_DATA_PASS_DETAILS_URL,

simulationPassesUrl: MONALISA_SIMULATION_PASSES_URL,

enableSynchronization: MONALISA_ENABLE_SYNCHRONIZATION?.toLowerCase() === 'true',
synchronizationPeriod: Number(MONALISA_SYNCHRONIZATION_PERIODS) || 3600000, // 1h in milisecond
},
Expand Down
3 changes: 2 additions & 1 deletion lib/database/adapters/DataPassAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class DataPassAdapter {
lastRunNumber,
} = databaseObject;

const runsCount = databaseObject.get('runsCount');
const { runs } = databaseObject;
const runsCount = runs ? runs[0]?.get('count') ?? 0 : null;

return {
id,
Expand Down
8 changes: 8 additions & 0 deletions lib/database/adapters/LhcFillAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class LhcFillAdapter {
*/
this.runAdapter = null;

/**
* @type {LhcFillStatisticsAdapter|null}
*/
this.statisticsAdapter = null;

this.toEntity = this.toEntity.bind(this);
this.toDatabase = this.toDatabase.bind(this);
}
Expand All @@ -43,8 +48,10 @@ class LhcFillAdapter {
beamType,
fillingSchemeName,
runs: sequelizeRuns,
statistics: sequelizeStatistics,
} = databaseObject;

const statistics = sequelizeStatistics ? this.statisticsAdapter.toEntity(sequelizeStatistics) : null;
const runs = (sequelizeRuns || []).map(this.runAdapter.toEntity);

return {
Expand All @@ -54,6 +61,7 @@ class LhcFillAdapter {
stableBeamsDuration,
beamType,
fillingSchemeName,
statistics,
runs,
};
}
Expand Down
3 changes: 2 additions & 1 deletion lib/database/adapters/LhcPeriodAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class LhcPeriodAdapter {
* @param {SequelizeLhcPeriod} databaseObject Object to convert.
* @returns {LhcPeriod} Converted entity object.
*/
toEntity({ id, name }) {
toEntity(databaseObject) {
const { id, name } = databaseObject;
return { id, name };
}

Expand Down
19 changes: 10 additions & 9 deletions lib/database/adapters/LhcPeriodStatisticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ class LhcPeriodStatisticsAdapter {
*/
toEntity(databaseObject) {
const { id, avgCenterOfMassEnergy, lhcPeriod } = databaseObject;
const distinctEnergies = databaseObject.get('distinctEnergies');
const beamType = databaseObject.get('beamType');
const dataPassesCount = databaseObject.get('dataPassesCount');

const runsCount = databaseObject.get('runsCount');
const entity = {
const distinctEnergies = databaseObject.get('distinctEnergies')?.split(',').map((energy) => parseFloat(energy)) || [];
const beamTypes = databaseObject.get('beamTypes')?.split(',') || [];
const dataPassesCount = databaseObject.get('dataPassesCount');

return {
id,
avgCenterOfMassEnergy,
distinctEnergies: distinctEnergies?.split(',').map((energy) => Number(energy)) ?? [],
beamType,
dataPassesCount,
runsCount,
distinctEnergies,
beamTypes,
dataPassesCount,
lhcPeriod: lhcPeriod ? this.lhcPeriodAdapter.toEntity(lhcPeriod) : null,
};
entity.lhcPeriod = lhcPeriod ? this.lhcPeriodAdapter.toEntity(lhcPeriod) : null;
return entity;
}
}

Expand Down
35 changes: 14 additions & 21 deletions lib/database/adapters/QualityControlFlagAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class QualityControlFlagAdapter {
constructor() {
this.toEntity = this.toEntity.bind(this);

this.qualityControlFlagReasonAdapter = null;
this.qualityControlFlagVerificationAdapter = null;
this.qualityControlFlagTypeAdapter = null;
this.userAdapter = null;
}

Expand All @@ -35,36 +34,30 @@ class QualityControlFlagAdapter {
toEntity(databaseObject) {
const {
id,
timeStart,
timeEnd,
from,
to,
comment,
provenance,
createdAt,
dataPassId,
runNumber,
detectorId,
userId,
dplDetectorId,
createdById,
user,
flagReasonId,
flagReason,
verifications,
flagTypeId,
flagType,
} = databaseObject;

return {
id,
timeStart: timeStart ? new Date(timeStart).getTime() : null,
timeEnd: timeEnd ? new Date(timeEnd).getTime() : null,
from: from ? new Date(from).getTime() : null,
to: to ? new Date(to).getTime() : null,
comment: comment ?? null,
provenance,
createdAt: createdAt ? new Date(createdAt).getTime() : null,
dataPassId,
runNumber,
detectorId,
userId,
dplDetectorId,
createdById,
user: user ? this.userAdapter.toEntity(user) : null,
flagReasonId,
flagReason: flagReason ? this.qualityControlFlagReasonAdapter.toEntity(flagReason) : null,
verifications: verifications?.map(this.qualityControlFlagVerificationAdapter.toEntity) ?? null,
flagTypeId,
flagType: flagType ? this.qualityControlFlagTypeAdapter.toEntity(flagType) : null,
createdAt: createdAt ? new Date(createdAt).getTime() : null,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/

/**
* QualityControlFlagReasonAdapter
* QualityControlFlagTypeAdapter
*/
class QualityControlFlagReasonAdapter {
class QualityControlFlagTypeAdapter {
/**
* Constructor
*/
Expand All @@ -25,26 +25,28 @@ class QualityControlFlagReasonAdapter {
/**
* Converts the given database object to an entity object.
*
* @param {SequelizeQualityControlFlagReason} databaseObject Object to convert.
* @returns {QualityControlFlagReason} Converted entity object.
* @param {SequelizeQualityControlFlagType} databaseObject Object to convert.
* @returns {QualityControlFlagType} Converted entity object.
*/
toEntity(databaseObject) {
const {
id,
name,
method,
bad,
obsolate,
archived,
archivedAt,
} = databaseObject;

return {
id,
name,
method,
bad,
obsolate,
archived,
archivedAt: archivedAt ? new Date(archivedAt).getTime() : null,
};
}
}

module.exports = { QualityControlFlagReasonAdapter };
module.exports = { QualityControlFlagTypeAdapter };
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,50 @@
*/

/**
* QualityControlFlagVerificationAdapter
* SimulationPassAdapter
*/
class QualityControlFlagVerificationAdapter {
class SimulationPassAdapter {
/**
* Constructor
*/
constructor() {
this.toEntity = this.toEntity.bind(this);
this.userAdapter = null;
}

/**
* Converts the given database object to an entity object.
*
* @param {SequelizeQualityControlFlagVerification} databaseObject Object to convert.
* @returns {QualityControlFlagVerification} Converted entity object.
* @param {SequelizeSimulationPass} databaseObject Object to convert.
* @returns {SimulationPass} Converted entity object.
*/
toEntity(databaseObject) {
const {
id,
comment,
userId,
user,
createdAt,
qualityControlFlagId,
name,
jiraId,
description,
pwg,
requestedEventsCount,
generatedEventsCount,
outputSize,
} = databaseObject;

const dataPassesCount = databaseObject.get('dataPassesCount');
const runsCount = databaseObject.get('runsCount');

return {
id,
userId,
user: user ? this.userAdapter.toEntity(user) : null,
comment: comment ?? null,
createdAt: createdAt ? new Date(createdAt).getTime() : null,
qualityControlFlagId,
name,
jiraId,
description,
pwg,
requestedEventsCount,
generatedEventsCount,
outputSize,
runsCount,
dataPassesCount,
};
}
}

module.exports = { QualityControlFlagVerificationAdapter };
module.exports = SimulationPassAdapter;
18 changes: 8 additions & 10 deletions lib/database/adapters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const LhcPeriodAdapter = require('./LhcPeriodAdapter');
const LhcPeriodStatisticsAdapter = require('./LhcPeriodStatisticsAdapter');
const DataPassAdapter = require('./DataPassAdapter');
const { QualityControlFlagAdapter } = require('./QualityControlFlagAdapter');
const { QualityControlFlagReasonAdapter } = require('./QualityControlFlagReasonAdapter');
const { QualityControlFlagVerificationAdapter } = require('./QualityControlFlagVerificationAdapter');
const { QualityControlFlagTypeAdapter } = require('./QualityControlFlagTypeAdapter');
const SimulationPassAdapter = require('./SimulationPassAdapter.js');

const attachmentAdapter = new AttachmentAdapter();
const detectorAdapter = new DetectorAdapter();
Expand Down Expand Up @@ -68,8 +68,8 @@ const lhcPeriodAdapter = new LhcPeriodAdapter();
const lhcPeriodStatisticsAdapter = new LhcPeriodStatisticsAdapter();
const dataPassAdapter = new DataPassAdapter();
const qualityControlFlagAdapter = new QualityControlFlagAdapter();
const qualityControlFlagReasonAdapter = new QualityControlFlagReasonAdapter();
const qualityControlFlagVerificationAdapter = new QualityControlFlagVerificationAdapter();
const qualityControlFlagTypeAdapter = new QualityControlFlagTypeAdapter();
const simulationPassAdapter = new SimulationPassAdapter();

// Fill dependencies
dplDetectorAdapter.dplProcessExecutionAdapter = dplProcessExecutionAdapter;
Expand All @@ -92,6 +92,7 @@ flpRoleAdapter.runAdapter = runAdapter;
hostAdapter.dplProcessExecutionAdapter = dplProcessExecutionAdapter;

lhcFillAdapter.runAdapter = runAdapter;
lhcFillAdapter.statisticsAdapter = lhcFillStatisticsAdapter;

logAdapter.runAdapter = runAdapter;
logAdapter.attachmentAdapter = attachmentAdapter;
Expand All @@ -112,10 +113,7 @@ runAdapter.lhcPeriodAdapter = lhcPeriodAdapter;
lhcPeriodStatisticsAdapter.lhcPeriodAdapter = lhcPeriodAdapter;

qualityControlFlagAdapter.userAdapter = userAdapter;
qualityControlFlagAdapter.qualityControlFlagReasonAdapter = qualityControlFlagReasonAdapter;
qualityControlFlagAdapter.qualityControlFlagVerificationAdapter = qualityControlFlagVerificationAdapter;

qualityControlFlagVerificationAdapter.userAdapter = userAdapter;
qualityControlFlagAdapter.qualityControlFlagTypeAdapter = qualityControlFlagTypeAdapter;

module.exports = {
attachmentAdapter,
Expand Down Expand Up @@ -145,6 +143,6 @@ module.exports = {
lhcPeriodStatisticsAdapter,
dataPassAdapter,
qualityControlFlagAdapter,
qualityControlFlagReasonAdapter,
qualityControlFlagVerificationAdapter,
qualityControlFlagTypeAdapter,
simulationPassAdapter,
};
Loading

0 comments on commit d4d0a5e

Please sign in to comment.