Commit 83adba8e authored by Curtis Adam's avatar Curtis Adam

Add an option to debug new users and refactor the leitner debug logs

parent de6f5e55
......@@ -166,7 +166,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
if (!Meteor.isServer && (!Meteor.userId() || Roles.userIsInRole(this.userId, 'blocked'))) {
throw new Meteor.Error("not-authorized");
} else {
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Set new active cards for " + user._id);
}
let algorithm = this.getBoxAlgorithm();
......@@ -176,7 +176,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
cardCount[i] = this.getCardCount(cardset._id, user._id, i + 1);
}
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Box Card Count: [" + cardCount + "]");
console.log("===> Maximum active cards: " + cardset.maxCards);
}
......@@ -265,7 +265,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
}
}
// Adjust the algorithm values to fill as many slots as possible
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Active Card cap for each box before adjustments: [" + boxActiveCardCap + "]");
}
return boxActiveCardCap;
......@@ -280,7 +280,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
missingCardCount.push(0);
}
}
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Missing Cards: [" + missingCardCount + "]");
}
let missingCardsSum = 0;
......@@ -290,7 +290,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
missingCardsSum += missingCardCount[i];
}
}
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Sum of missing cards: " + missingCardsSum);
}
let fillUpCount = 0;
......@@ -328,7 +328,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
}
}
}
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Active Card cap for each box after adjustments: [" + boxActiveCardCap + "]");
console.log("===> " + randomSelectedCards.length + " new active Cards: [" + randomSelectedCards + "]");
}
......@@ -381,7 +381,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
}
}
}
if (Meteor.settings.debugServer && Meteor.isServer) {
if (Meteor.settings.debug.leitner && Meteor.isServer) {
console.log("===> Active Card cap for each box after adjustments: [" + boxActiveCardCap + "]");
console.log("===> " + nextCards.length + " new active Cards: [" + nextCards + "]");
}
......@@ -396,7 +396,7 @@ export let LeitnerUtilities = class LeitnerUtilities {
if (!Meteor.isServer) {
throw new Meteor.Error("not-authorized");
} else {
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("===> Reset cards");
}
let query = {cardset_id: cardset._id, user_id: user._id, box: {$ne: 6}};
......
import {Accounts} from 'meteor/accounts-base';
import {ServerStyle} from "../../api/styles";
import {Meteor} from "meteor/meteor";
ServiceConfiguration.configurations.remove({
service: 'facebook'
......@@ -30,6 +32,13 @@ ServiceConfiguration.configurations.insert({
secret: Meteor.settings.google.secret
});
Accounts.validateNewUser((user) => {
if (Meteor.settings.debug.login) {
console.log("----------New User----------");
console.log(user);
console.log("----------New User----------");
}
});
Meteor.users.after.insert(function (userId, doc) {
// Setup roles for backdoor login, required for acceptance tests
......
......@@ -90,7 +90,7 @@ Meteor.methods({
let cardsets = getCardsets();
let cardsetCount = 0;
let currentCardsetWithLearners = 1;
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
for (let i = 0; i < cardsets.length; i++) {
if (Leitner.findOne({cardset_id: cardsets[i]._id})) {
cardsetCount++;
......@@ -100,12 +100,12 @@ Meteor.methods({
for (let i = 0; i < cardsets.length; i++) {
let learners = getLearners(cardsets[i]._id);
let learnerCount = learners.length;
if (Meteor.settings.debugServer && learnerCount > 0) {
if (Meteor.settings.debug.leitner && learnerCount > 0) {
console.log("\nCardset " + currentCardsetWithLearners++ + " of " + cardsetCount + ": [" + cardsets[i].name + ", " + cardsets[i]._id + "]");
}
for (let k = 0; k < learners.length; k++) {
if (!Bonus.isInBonus(cardsets[i]._id, learners[k].user_id) || cardsets[i].learningEnd.getTime() > new Date().getTime()) {
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("=>User " + (k + 1) + " of " + learnerCount + ": " + learners[k].user_id);
}
let activeCard = getActiveCard(cardsets[i]._id, learners[k].user_id);
......@@ -117,7 +117,7 @@ Meteor.methods({
} else {
Meteor.call('prepareMail', cardsets[i], user);
Meteor.call('prepareWebpush', cardsets[i], user);
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("===> Nothing to do");
}
}
......@@ -134,12 +134,12 @@ Meteor.methods({
if (user.mailNotification && mailsEnabled() && !isNewcomer && Roles.userIsInRole(user._id, ['admin', 'editor', 'university', 'lecturer', 'pro']) && !Roles.userIsInRole(user._id, ['blocked', 'firstLogin'])) {
try {
if (isReset) {
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("===> Sending E-Mail reset Message");
}
MailNotifier.prepareMailReset(cardset, user._id);
} else {
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("===> Sending E-Mail reminder Message");
}
MailNotifier.prepareMail(cardset, user._id);
......@@ -155,7 +155,7 @@ Meteor.methods({
if ((Bonus.isInBonus(cardset._id, user._id) || user.webNotification) && !isNewcomer) {
try {
let web = new WebNotifier();
if (Meteor.settings.debugServer) {
if (Meteor.settings.debug.leitner) {
console.log("===> Sending Webpush reminder Message");
}
web.prepareWeb(cardset, user._id);
......
......@@ -51,5 +51,8 @@
"language": "de",
"url": "smtp://postmaster%40sandboxcc4938befa8447ca8c857cdf4b968653.mailgun.org:d07ea9c40ccbb21d268bbda17e9aad9d@smtp.mailgun.org:587"
},
"debugServer": false
"debug": {
"leitner": false,
"login": false
}
}
......@@ -50,5 +50,8 @@
"language": "de",
"url": "smtp://postmaster%40sandboxcc4938befa8447ca8c857cdf4b968653.mailgun.org:d07ea9c40ccbb21d268bbda17e9aad9d@smtp.mailgun.org:587"
},
"debugServer": true
"debug": {
"leitner": true,
"login": true
}
}
......@@ -50,5 +50,8 @@
"language": "de",
"url": "smtp://postmaster%40sandboxcc4938befa8447ca8c857cdf4b968653.mailgun.org:d07ea9c40ccbb21d268bbda17e9aad9d@smtp.mailgun.org:587"
},
"debugServer": false
"debug": {
"leitner": false,
"login": false
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment