From e3647ae226d19ed1401d4c617d35a68de1c4657a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 May 2016 17:25:05 +0200 Subject: Rename pool requests --> requests scheduler --- server/models/poolRequests.js | 55 ------------------------------------------- server/models/requests.js | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 server/models/poolRequests.js create mode 100644 server/models/requests.js (limited to 'server/models') diff --git a/server/models/poolRequests.js b/server/models/poolRequests.js deleted file mode 100644 index 28093a94c..000000000 --- a/server/models/poolRequests.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict' - -const mongoose = require('mongoose') - -const logger = require('../helpers/logger') - -// --------------------------------------------------------------------------- - -const poolRequestsSchema = mongoose.Schema({ - type: String, - id: String, // Special id to find duplicates (video created we want to remove...) - request: mongoose.Schema.Types.Mixed -}) -const PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema) - -// --------------------------------------------------------------------------- - -const PoolRequests = { - create: create, - findById: findById, - list: list, - removeRequestById: removeRequestById, - removeRequests: removeRequests -} - -function create (id, type, request, callback) { - PoolRequestsDB.create({ id: id, type: type, request: request }, callback) -} - -function findById (id, callback) { - PoolRequestsDB.findOne({ id: id }, callback) -} - -function list (callback) { - PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) -} - -function removeRequestById (id, callback) { - PoolRequestsDB.remove({ id: id }, callback) -} - -function removeRequests (ids) { - PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) { - if (err) { - logger.error('Cannot remove requests from the pool requests database.', { error: err }) - return // Abort - } - - logger.info('Pool requests flushed.') - }) -} - -// --------------------------------------------------------------------------- - -module.exports = PoolRequests diff --git a/server/models/requests.js b/server/models/requests.js new file mode 100644 index 000000000..2152ae0e9 --- /dev/null +++ b/server/models/requests.js @@ -0,0 +1,55 @@ +'use strict' + +const mongoose = require('mongoose') + +const logger = require('../helpers/logger') + +// --------------------------------------------------------------------------- + +const requestsSchema = mongoose.Schema({ + type: String, + id: String, // Special id to find duplicates (video created we want to remove...) + request: mongoose.Schema.Types.Mixed +}) +const RequestsDB = mongoose.model('requests', requestsSchema) + +// --------------------------------------------------------------------------- + +const Requests = { + create: create, + findById: findById, + list: list, + removeRequestById: removeRequestById, + removeRequests: removeRequests +} + +function create (id, type, request, callback) { + RequestsDB.create({ id: id, type: type, request: request }, callback) +} + +function findById (id, callback) { + RequestsDB.findOne({ id: id }, callback) +} + +function list (callback) { + RequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) +} + +function removeRequestById (id, callback) { + RequestsDB.remove({ id: id }, callback) +} + +function removeRequests (ids) { + RequestsDB.remove({ _id: { $in: ids } }, function (err) { + if (err) { + logger.error('Cannot remove requests from the requests database.', { error: err }) + return // Abort + } + + logger.info('Pool requests flushed.') + }) +} + +// --------------------------------------------------------------------------- + +module.exports = Requests -- cgit v1.2.3