Skip to content

Commit

Permalink
Merge pull request #4771 from Cookiezaurs/master-populator
Browse files Browse the repository at this point in the history
[populator]fixes for populator plugin
  • Loading branch information
Cookiezaurs authored Dec 13, 2023
2 parents 595defb + ce60a1e commit 90de16e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
75 changes: 42 additions & 33 deletions plugins/populator/frontend/public/javascripts/countly.models.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,13 @@

this.hasSession = false;
this.ip = predefined_ip_addresses[Math.floor(chance.random() * (predefined_ip_addresses.length - 1))];
if ((totalCountWithoutUserProps < totalUserCount / 3)) {
if ((totalUserCount % 3 === 0)) {
this.userdetails = { custom: getUserProperties(templateUp) };
totalCountWithoutUserProps++;
}
else {
this.userdetails = { name: chance.name(), username: chance.twitter().substring(1), email: chance.email(), organization: capitaliseFirstLetter(chance.word()), phone: chance.phone(), gender: chance.gender().charAt(0), byear: chance.birthday().getFullYear(), custom: getUserProperties(templateUp) };
}
totalUserCount++;
this.userdetails.custom.populator = true;
this.metrics = {};
this.startTs = startTs;
Expand Down Expand Up @@ -1015,7 +1015,6 @@
var usersForAb = [];
var userAmount = 1000;
var totalUserCount = 0;
var totalCountWithoutUserProps = 0;
var queued = 0;
var abExampleCount = 1;
var abExampleName = "Pricing";
Expand Down Expand Up @@ -1512,27 +1511,27 @@
});
});
}

generateRatingWidgets(function() {
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys")) {
generateNPSWidgets(function() {
setTimeout(function() {
generateSurveyWidgets1(done);
}, 1000);

setTimeout(function() {
generateSurveyWidgets2(done);
}, 3000);

setTimeout(function() {
generateSurveyWidgets3(done);
}, 5000);
});
}
else {
done();
}
});
if (countlyGlobal.plugins.indexOf("star-rating") !== -1 && countlyAuth.validateCreate("star-rating")) {
generateRatingWidgets(function() {
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys")) {
generateNPSWidgets(function() {
setTimeout(function() {
generateSurveyWidgets1(function() {
generateSurveyWidgets2(function() {
generateSurveyWidgets3(done);
});
});
}, 1000);
});
}
else {
done();
}
});
}
else {
done();
}
}


Expand Down Expand Up @@ -1728,8 +1727,6 @@
idCount++;
}

totalUserCount += userAmount + retentionCall; // campaign users
totalCountWithoutUserProps = 0;

generateRetentionUser(ts, userCount--, ids, template, function() {
ts += 60 * 60 * 24;
Expand Down Expand Up @@ -1910,14 +1907,24 @@
* @param {object} u - user object
**/
function processUsers() {
for (var userAmountIndex = 0; userAmountIndex < amount; userAmountIndex++) {
processUser(users[userAmountIndex]);
}
if (users.length > 0 && generating) {
setTimeout(processUsers, timeout);
if (bulk.length < 10) {
for (var userAmountIndex = 0; userAmountIndex < amount; userAmountIndex++) {
processUser(users[userAmountIndex]);
}
if (users.length > 0 && generating) {
setTimeout(processUsers, timeout);
}
else {
countlyPopulator.sync(true);
}
}
else {
countlyPopulator.sync(true);
if (generating) {
setTimeout(processUsers, timeout);
}
else {
countlyPopulator.sync(true);
}
}
}
/**
Expand All @@ -1932,7 +1939,9 @@

generateWidgets(function() {
generateRetention(template, function() {
countlyPopulator.sync(true);
generateCampaigns(function() {
countlyPopulator.sync(true);
for (var campaignAmountIndex = 0; campaignAmountIndex < amount; campaignAmountIndex++) {
createUser();
}
Expand Down Expand Up @@ -2000,7 +2009,7 @@
};

countlyPopulator.sync = function(force) {
if (generating && (force || bulk.length > bucket) && !countlyPopulator.bulking) {
if (generating && (force || bulk.length > 1) && !countlyPopulator.bulking) {
queued++;
var mult = Math.round(queued / 10) + 1;
timeout = bucket * 10 * mult * mult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@

countlyPopulator.setSelectedTemplate(self.selectedTemplate);
countlyPopulator.getTemplate(self.selectedTemplate, function(template) {
countlyPopulator.generateUsers(self.maxTime * 4, template);
countlyPopulator.generateUsers(self.maxTime, template);
});
var startTime = Math.round(Date.now() / 1000);
this.progressBar = setInterval(function() {
Expand Down

0 comments on commit 90de16e

Please sign in to comment.