2016-11-14 19:57:10 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
export default function clearBreakouts(breakoutId) {
|
|
|
|
if (breakoutId) {
|
2016-11-25 03:22:04 +08:00
|
|
|
const selector = {
|
2017-10-12 05:25:18 +08:00
|
|
|
breakoutId,
|
2016-11-25 03:22:04 +08:00
|
|
|
};
|
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
|
|
|
const numberAffected = Breakouts.remove(selector);
|
2016-11-17 23:20:40 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Breakouts (${breakoutId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing Breakouts (${breakoutId})`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
const numberAffected = Breakouts.remove({});
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Breakouts (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error('Error on clearing Breakouts (all)');
|
|
|
|
}
|
|
|
|
}
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|