diff --git a/services/backend/src/routes/updater.js b/services/backend/src/routes/updater.js index ebc77a24ef..47a74de1aa 100644 --- a/services/backend/src/routes/updater.js +++ b/services/backend/src/routes/updater.js @@ -9,7 +9,6 @@ const { updateSISRedisCache, updateSISStudents, updateStudentsByStudentNumber, - updateStudentsIndividually, } = require('../services/sisUpdaterService') const logger = require('../util/logger') const { jobMaker, getJobs } = require('../worker/queue') @@ -38,11 +37,6 @@ router.get('/update/v2/students', async (_req, res) => { } }) -router.get('/update/v2/students_individually', async (_req, res) => { - await updateStudentsIndividually() - res.status(200).send() -}) - router.post('/update/v2/customlist/:type', async (req, res) => { const { type } = req.params const list = req.body diff --git a/services/backend/src/services/sisUpdaterService.js b/services/backend/src/services/sisUpdaterService.js index 44ad7dfb8b..9240701925 100644 --- a/services/backend/src/services/sisUpdaterService.js +++ b/services/backend/src/services/sisUpdaterService.js @@ -2,8 +2,7 @@ const axios = require('axios') const { Op } = require('sequelize') const { SIS_UPDATER_URL, SECRET_TOKEN } = require('../conf-backend') -const { Studyplan, Student, StudyrightElement } = require('../models') -const logger = require('../util/logger') +const { Studyplan } = require('../models') const client = axios.create({ baseURL: SIS_UPDATER_URL }) @@ -40,37 +39,6 @@ const updateSISRedisCache = async () => { const response = await client.get('/v1/rediscache', params) return response.data } -const delay = time => { - return new Promise(res => { - setTimeout(res, time) - }) -} - -const updateStudentsIndividually = async () => { - try { - const studentNumbers = await Student.findAll({ - attributes: ['studentnumber'], - include: { - model: StudyrightElement, - where: { - code: { [Op.regexp]: '(KH*|MH*)' }, - }, - }, - }) - const uniqueStudents = [...new Set(studentNumbers.map(s => s.studentnumber))] - const chunkSize = 4000 - for (let from = 0; from < uniqueStudents.length - chunkSize; from += chunkSize) { - await client.post( - 'v1/students', - { studentnumbers: uniqueStudents.slice(from, from + chunkSize), individualMode: true }, - params - ) - await delay(200) - } - } catch (e) { - logger.error(e) - } -} const studyplansUpdate = async days => { const limitDate = new Date() @@ -100,5 +68,4 @@ module.exports = { abort, updateCoursesByCourseCode, studyplansUpdate, - updateStudentsIndividually, } diff --git a/services/frontend/src/components/Updater/index.jsx b/services/frontend/src/components/Updater/index.jsx index cd0ce76bed..2f4501f986 100644 --- a/services/frontend/src/components/Updater/index.jsx +++ b/services/frontend/src/components/Updater/index.jsx @@ -26,7 +26,6 @@ export const Updater = () => { const updateSISMeta = () => apiCall('meta', '/updater/update/v2/meta', 'get') const updateSISStudents = () => apiCall('students', '/updater/update/v2/students', 'get') - const updateSISStudentsIndividually = () => apiCall('students', '/updater/update/v2/students_individually', 'get') const updateSISProgrammes = () => apiCall('curriculums', '/updater/update/v2/programmes') const updateSISCustomList = () => apiCall('custom list', `/updater/update/v2/customlist/${type}`, 'post', customList.trim().split('\n')) @@ -99,7 +98,6 @@ export const Updater = () => { - { diff --git a/updater/sis-updater-scheduler/src/scheduler.js b/updater/sis-updater-scheduler/src/scheduler.js index 7d9cac3c23..71cb4a21cb 100644 --- a/updater/sis-updater-scheduler/src/scheduler.js +++ b/updater/sis-updater-scheduler/src/scheduler.js @@ -202,13 +202,13 @@ const getHourlyPersonsToUpdate = async () => { ) } -const scheduleByStudentNumbers = async (studentNumbers, individualMode = false) => { +const scheduleByStudentNumbers = async studentNumbers => { logger.info('Scheduling by student numbers') const { knex } = knexConnection const personsToUpdate = await knex('persons').column('id', 'student_number').whereIn('student_number', studentNumbers) await eachLimit( - chunk(personsToUpdate, individualMode ? 1 : CHUNK_SIZE), + chunk(personsToUpdate, CHUNK_SIZE), 10, async s => await createJobs(s, 'students', SIS_MISC_SCHEDULE_CHANNEL) ) diff --git a/updater/sis-updater-scheduler/src/server.js b/updater/sis-updater-scheduler/src/server.js index 01157efc71..46b93d576a 100644 --- a/updater/sis-updater-scheduler/src/server.js +++ b/updater/sis-updater-scheduler/src/server.js @@ -84,12 +84,11 @@ app.get('/v1/programmes', async (_, res) => { }) app.post('/v1/students', async (req, res) => { - const { individualMode } = req.body const studentnumbers = req.body.studentnumbers.map(n => (n[0] === '0' ? n : `0${n}`)) - logger.info(`Scheduling ${studentnumbers.length} custom studentnumbers ${individualMode ? 'individually' : ''}`) + logger.info(`Scheduling ${studentnumbers.length} custom studentnumbers`) - await scheduleByStudentNumbers(studentnumbers, individualMode) + await scheduleByStudentNumbers(studentnumbers) res.locals.msg('Scheduled studentnumbers') })