Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions lib/database/adapters/GaqSummaryAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

/**
* GaqSummaryAdapter
*/
class GaqSummaryAdapter {
/**
* Constructor
*/
constructor() {
this.toEntity = this.toEntity.bind(this);
}

/**
* Converts the given database object to an entity object.
*
* @param {SequelizeGaqSummary} databaseObject Object to convert.
* @returns {GaqSummary} Converted entity object.
*/
toEntity(databaseObject) {
const {
dataPassId,
runNumber,
badRunCoverage,
explicitlyNotBadRunCoverage,
mcReproducibleCoverage,
missingVerificationsCount,
undefinedQualityPeriodsCount,
notComputable,
invalidatedAt,
createdAt,
updatedAt,
} = databaseObject;

return {
dataPassId,
runNumber,
badRunCoverage,
explicitlyNotBadRunCoverage,
mcReproducibleCoverage,
missingVerificationsCount,
undefinedQualityPeriodsCount,
notComputable,
invalidatedAt,
createdAt,
updatedAt,
};
}
}

module.exports = { GaqSummaryAdapter };
3 changes: 3 additions & 0 deletions lib/database/adapters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const EorReasonAdapter = require('./EorReasonAdapter');
const FlpRoleAdapter = require('./FlpRoleAdapter');
const { HostAdapter } = require('./HostAdapter.js');
const { GaqDetectorAdapter } = require('./GaqDetectorAdapter.js');
const { GaqSummaryAdapter } = require('./GaqSummaryAdapter.js');
const { LhcFillAdapter } = require('./LhcFillAdapter.js');
const { LhcFillStatisticsAdapter } = require('./LhcFillStatisticsAdapter.js');
const LhcPeriodAdapter = require('./LhcPeriodAdapter');
Expand Down Expand Up @@ -63,6 +64,7 @@ const environmentHistoryItemAdapter = new EnvironmentHistoryItemAdapter();
const eorReasonAdapter = new EorReasonAdapter();
const flpRoleAdapter = new FlpRoleAdapter();
const gaqDetectorAdapter = new GaqDetectorAdapter();
const gaqSummaryAdapter = new GaqSummaryAdapter();
const hostAdapter = new HostAdapter();
const lhcFillAdapter = new LhcFillAdapter();
const lhcFillStatisticsAdapter = new LhcFillStatisticsAdapter();
Expand Down Expand Up @@ -159,6 +161,7 @@ module.exports = {
eorReasonAdapter,
flpRoleAdapter,
gaqDetectorAdapter,
gaqSummaryAdapter,
hostAdapter,
lhcFillAdapter,
lhcFillStatisticsAdapter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable('gaq_summaries', {
data_pass_id: {
type: Sequelize.INTEGER,
primaryKey: true,
allowNull: false,
references: {
model: 'data_passes',
key: 'id',
},
},
run_number: {
type: Sequelize.INTEGER,
primaryKey: true,
allowNull: false,
references: {
model: 'runs',
key: 'run_number',
},
},
bad_run_coverage: {
type: Sequelize.FLOAT,
},
explicitly_not_bad_run_coverage: {
type: Sequelize.FLOAT,
},
mc_reproducible_coverage: {
type: Sequelize.FLOAT,
},
missing_verifications_count: {
type: Sequelize.INTEGER,
},
undefined_quality_periods_count: {
type: Sequelize.INTEGER,
},
not_computable: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false,
},
invalidated_at: {
type: Sequelize.DATE(3),
allowNull: true,
defaultValue: null,
},
created_at: {
type: Sequelize.DATE(3),
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
},
updated_at: {
type: Sequelize.DATE(3),
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)'),
},
}, { transaction });

await queryInterface.addIndex('gaq_summaries', {
name: 'gaq_summaries_invalidated_at_idx',
fields: ['invalidated_at'],
}, { transaction });
}),

down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.dropTable('gaq_summaries', { transaction });
}),
};
57 changes: 57 additions & 0 deletions lib/database/models/gaqSummary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

module.exports = (sequelize) => {
const Sequelize = require('sequelize');

const GaqSummary = sequelize.define('GaqSummary', {
dataPassId: {
type: Sequelize.INTEGER,
primaryKey: true,
},
runNumber: {
type: Sequelize.INTEGER,
primaryKey: true,
},
badRunCoverage: {
type: Sequelize.FLOAT,
},
explicitlyNotBadRunCoverage: {
type: Sequelize.FLOAT,
},
mcReproducibleCoverage: {
type: Sequelize.FLOAT,
},
missingVerificationsCount: {
type: Sequelize.INTEGER,
},
undefinedQualityPeriodsCount: {
type: Sequelize.INTEGER,
},
notComputable: {
type: Sequelize.BOOLEAN,
},
invalidatedAt: {
type: Sequelize.DATE(3),
},
}, { tableName: 'gaq_summaries' });

GaqSummary.removeAttribute('id');

GaqSummary.associate = (models) => {
GaqSummary.belongsTo(models.Run, { foreignKey: 'runNumber', as: 'run' });
GaqSummary.belongsTo(models.DataPass, { foreignKey: 'dataPassId', as: 'dataPass' });
};

return GaqSummary;
};
2 changes: 2 additions & 0 deletions lib/database/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const EorReason = require('./eorreason');
const EpnRoleSession = require('./epnrolesession');
const FlpRole = require('./flprole');
const GaqDetector = require('./gaqDetector.js');
const GaqSummary = require('./gaqSummary.js');
const Host = require('./host.js');
const LhcFill = require('./lhcFill');
const LhcFillStatistics = require('./lhcFillStatistics.js');
Expand Down Expand Up @@ -66,6 +67,7 @@ module.exports = (sequelize) => {
EpnRoleSessionkey: EpnRoleSession(sequelize),
FlpRole: FlpRole(sequelize),
GaqDetector: GaqDetector(sequelize),
GaqSummary: GaqSummary(sequelize),
Host: Host(sequelize),
LhcFill: LhcFill(sequelize),
LhcFillStatistics: LhcFillStatistics(sequelize),
Expand Down
33 changes: 33 additions & 0 deletions lib/database/repositories/GaqSummaryRepository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

const {
models: {
GaqSummary,
},
} = require('..');
const Repository = require('./Repository');

/**
* GaqSummary repository
*/
class GaqSummaryRepository extends Repository {
/**
* Creates a new `GaqSummaryRepository` instance.
*/
constructor() {
super(GaqSummary);
}
}

module.exports = new GaqSummaryRepository();
2 changes: 2 additions & 0 deletions lib/database/repositories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const EnvironmentRepository = require('./EnvironmentRepository');
const EorReasonRepository = require('./EorReasonRepository');
const FlpRoleRepository = require('./FlpRoleRepository');
const GaqDetectorRepository = require('./GaqDetectorRepository.js');
const GaqSummaryRepository = require('./GaqSummaryRepository.js');
const HostRepository = require('./HostRepository.js');
const LhcFillRepository = require('./LhcFillRepository');
const LhcFillStatisticsRepository = require('./LhcFillStatisticsRepository.js');
Expand Down Expand Up @@ -70,6 +71,7 @@ module.exports = {
EorReasonRepository,
FlpRoleRepository,
GaqDetectorRepository,
GaqSummaryRepository,
HostRepository,
LhcFillRepository,
LhcFillStatisticsRepository,
Expand Down
Loading