-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per-Test status updates - basic queries and endpoints
- Loading branch information
Showing
11 changed files
with
347 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
server/migrations/20240404171101-addCollectionJobTestStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(async transaction => { | ||
await queryInterface.createTable( | ||
'CollectionJobTestStatus', | ||
{ | ||
id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true | ||
}, | ||
testId: { | ||
type: Sequelize.STRING, | ||
allowNull: false | ||
}, | ||
collectionJobId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE', | ||
references: { | ||
model: 'CollectionJob', | ||
key: 'id' | ||
} | ||
}, | ||
status: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
defaultValue: 'QUEUED' | ||
} | ||
}, | ||
{ transaction } | ||
); | ||
await queryInterface.addConstraint('CollectionJobTestStatus', { | ||
type: 'unique', | ||
name: 'CollectionJob_Test_unique', | ||
fields: ['collectionJobId', 'testId'], | ||
transaction | ||
}); | ||
}); | ||
}, | ||
|
||
async down(queryInterface) { | ||
return queryInterface.sequelize.transaction(async transaction => { | ||
await queryInterface.removeConstraint( | ||
'CollectionJobTestStatus', | ||
'CollectionJob_Test_unique', | ||
{ transaction } | ||
); | ||
await queryInterface.dropTable('CollectionJobTestStatus', { | ||
transaction | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { COLLECTION_JOB_STATUS } = require('../util/enums'); | ||
|
||
const MODEL_NAME = 'CollectionJobTestStatus'; | ||
|
||
module.exports = function (sequelize, DataTypes) { | ||
const Model = sequelize.define( | ||
MODEL_NAME, | ||
{ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true | ||
}, | ||
collectionJobId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: 'CollectionJob', | ||
key: 'id' | ||
} | ||
}, | ||
testId: { | ||
type: DataTypes.STRING, | ||
allowNull: null | ||
}, | ||
status: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
defaultValue: COLLECTION_JOB_STATUS.QUEUED | ||
} | ||
}, | ||
{ | ||
timestamps: false, | ||
tableName: MODEL_NAME | ||
} | ||
); | ||
|
||
Model.associate = function (models) { | ||
Model.belongsTo(models.CollectionJob, { | ||
foreignKey: 'collectionJobId', | ||
targetKey: 'id', | ||
as: 'collectionJob', | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE' | ||
}); | ||
}; | ||
|
||
Model.QUEUED = COLLECTION_JOB_STATUS.QUEUED; | ||
Model.RUNNING = COLLECTION_JOB_STATUS.RUNNING; | ||
Model.COMPLETED = COLLECTION_JOB_STATUS.COMPLETED; | ||
Model.CANCELLED = COLLECTION_JOB_STATUS.CANCELLED; | ||
Model.ERROR = COLLECTION_JOB_STATUS.ERROR; | ||
|
||
return Model; | ||
}; |
Oops, something went wrong.