mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Fixed Menu Clean up.
This commit is contained in:
parent
839390f820
commit
aaddbf0b44
1 changed files with 1 additions and 34 deletions
|
|
@ -82,40 +82,7 @@ Meteor.methods({
|
||||||
throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.');
|
throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let removeMenuIds = [];
|
return await Menus.removeAsync({ menuComplete: true });
|
||||||
|
|
||||||
|
|
||||||
// let's find all the menus with menu items that are past their date.
|
|
||||||
let menuList = Menus.find({ menuComplete: false }).fetch();
|
|
||||||
for (i=0; i < menuList.length; i++) {
|
|
||||||
let removeMenu = true;
|
|
||||||
let items = MenuItems.find({ menuId: menuList[i]._id }).fetch();
|
|
||||||
for (let j=0; j < items.length; j++) {
|
|
||||||
let srvDate = moment(items[j].serveDateActual);
|
|
||||||
let today = moment();
|
|
||||||
let expired = moment(today).isAfter(srvDate);
|
|
||||||
if (expired != true) {
|
|
||||||
removeMenu = false;
|
|
||||||
}
|
|
||||||
if (j == items.length - 1) {
|
|
||||||
if (removeMenu == true) {
|
|
||||||
removeMenuIds.push(menuList[i]._id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// next let's add the ids of any menus that are marked complete
|
|
||||||
let markedComplete = Menus.find({ menuComplete: true }).fetch();
|
|
||||||
for (let k = 0; k < markedComplete.length; k++) {
|
|
||||||
let menuId = markedComplete[k]._id;
|
|
||||||
removeMenuIds.push(menuId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally we'll cycle through the ids and remove the items we collected up.
|
|
||||||
for (let l = 0; l < removeMenuIds.length; l++) {
|
|
||||||
await Menus.removeAsync({ _id: removeMenuIds[l] });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
|
async 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
|
||||||
check(menuId, String);
|
check(menuId, String);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue