-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workerMonitoring): add model & logic (#39)
* feat(workerMonitoring): add model & logic * fix test * Review : add debounce & update migration of workerMonitoring * Review: add NO_ASYNC in debounce * Add default env variables for test * Fix snapshot
- Loading branch information
1 parent
970ba94
commit 6c1f25e
Showing
14 changed files
with
430 additions
and
4 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
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,14 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
function WorkerMonitoringConfiguration(types, models) { | ||
return { | ||
model: models.workerMonitoring, | ||
actions: ['list'], | ||
list: { | ||
before: function (findOptions) { | ||
return findOptions; | ||
} | ||
} | ||
}; | ||
} | ||
exports["default"] = WorkerMonitoringConfiguration; |
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,39 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var sequelize_1 = require("sequelize"); | ||
function WorkerMonitoring(sequelize) { | ||
var WorkerMonitoring = sequelize.define('workerMonitoring', { | ||
id: { | ||
type: sequelize_1.DataTypes.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true | ||
}, | ||
workerId: { | ||
type: sequelize_1.DataTypes.INTEGER, | ||
allowNull: false | ||
}, | ||
lastCalledAt: { | ||
type: sequelize_1.DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
createdAt: { | ||
type: sequelize_1.DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updatedAt: { | ||
type: sequelize_1.DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
deletedAt: { | ||
type: sequelize_1.DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: null | ||
} | ||
}, { | ||
freezeTableName: true, | ||
tableName: 'workerMonitoring', | ||
paranoid: true | ||
}); | ||
return WorkerMonitoring; | ||
} | ||
exports["default"] = WorkerMonitoring; |
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,34 @@ | ||
'use strict' | ||
module.exports = { | ||
up: function (queryInterface, Sequelize) { | ||
return queryInterface.createTable('workerMonitoring', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER, | ||
}, | ||
workerId: { | ||
type: Sequelize.STRING, | ||
}, | ||
lastCalledAt: { | ||
type: Sequelize.STRING, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
deletedAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE, | ||
}, | ||
}) | ||
}, | ||
down: function (queryInterface) { | ||
return queryInterface.dropTable('workerMonitoring') | ||
}, | ||
} |
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
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,20 @@ | ||
import { | ||
InAndOutTypes, | ||
ModelDeclarationType, | ||
SequelizeModels, | ||
} from 'graphql-sequelize-generator/types' | ||
|
||
export default function WorkerMonitoringConfiguration( | ||
types: InAndOutTypes, | ||
models: SequelizeModels | ||
): ModelDeclarationType { | ||
return { | ||
model: models.workerMonitoring, | ||
actions: ['list'], | ||
list: { | ||
before: (findOptions) => { | ||
return findOptions | ||
}, | ||
}, | ||
} | ||
} |
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,41 @@ | ||
import { DataTypes } from 'sequelize' | ||
|
||
export default function WorkerMonitoring(sequelize: any) { | ||
var WorkerMonitoring = sequelize.define( | ||
'workerMonitoring', | ||
{ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
workerId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
lastCalledAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
}, | ||
deletedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: null, | ||
}, | ||
}, | ||
{ | ||
freezeTableName: true, | ||
tableName: 'workerMonitoring', | ||
paranoid: true, | ||
} | ||
) | ||
return WorkerMonitoring | ||
} |
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,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test the workerMonitoring endpoint WorkerMonitoring is updated when a new job is acquired 1`] = ` | ||
Object { | ||
"acquireJob": Object { | ||
"id": 6, | ||
"name": null, | ||
"output": null, | ||
"status": "processing", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Test the workerMonitoring endpoint WorkerMonitoring is updated when a new job is acquired 2`] = ` | ||
Object { | ||
"acquireJob": Object { | ||
"id": 7, | ||
"name": null, | ||
"output": null, | ||
"status": "processing", | ||
}, | ||
} | ||
`; |
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,3 @@ | ||
exports.cleanupTestsEnv = () => { | ||
process.env.NO_ASYNC = true | ||
} |
Oops, something went wrong.