Website: Update trial usage script (#41023)

Changes:
- Updated the script that reports Render trial information to use
`sails.helpers.flow.simultaneouslyForEach` to improve the speed of the
script.
This commit is contained in:
Eric
2026-03-04 17:08:08 -06:00
committed by GitHub
parent cb38c3ea47
commit b7abab942c
+5 -6
View File
@@ -36,8 +36,8 @@ module.exports = {
sails.log(`Reporting Render trial usage information for ${renderTrialInstancesToSendAnalyticsFor.length} trial instances`);
await sails.helpers.flow.simultaneouslyForEach(renderTrialInstancesToSendAnalyticsFor, async (renderTrial)=>{
for(let renderTrial of renderTrialInstancesToSendAnalyticsFor) {
let lastReportedStatisticsForThisTrial = await HistoricalUsageSnapshot.find({
organization: 'Render-trial-'+renderTrial.slug,
}).sort('createdAt DESC').limit(1);
@@ -51,13 +51,13 @@ module.exports = {
if(lastReportedStatisticsForThisTrial.length < 1) {
// If we didn't find usage statistics reported by a Render trial instance, log a warning and continue.
sails.log(`Skipping reporting information for a trial instance (slug: ${renderTrial.slug}). No usage analytics were found reported by this Render trial`);
continue;
return;
}
let thisRenderTrialsUser = await User.findOne({id: renderTrial.user});
if(!thisRenderTrialsUser) {
// If the user record associated with this Render trial is missing, (e.g., if this person requested that we delete their account) log a warning and continue.
sails.log(`Skipping reporting information for a trial instance (slug: ${renderTrial.slug}). No user could be found that was associated with this Render trial.`);
continue;
return;
}
// Create a formatted timestamp of when this Render trial was started (When this user signed up)
let renderTrialStartedOn = new Date(thisRenderTrialsUser.createdAt);
@@ -82,7 +82,7 @@ module.exports = {
let emailDomain = thisRenderTrialsUser.emailAddress.split('@')[1];
if(emailDomain.toLowerCase() === 'fleetdm.com'){
sails.log(`Skipping reporting usage information for a Render trial instance (slug: ${renderTrial.slug}) because it is used by a fleetdm.com email address`);
continue;
return;
}
// Update the contact record that was created for this user when they signed up.
@@ -96,8 +96,7 @@ module.exports = {
sails.log.warn(`When reporting usage information about a Render trial instance (slug: ${renderTrial.slug}), an error occured when updating/creating a Salesforce contact/account. Full error: ${require('util').inspect(err)}`);
});
}// After each Render trial Instance
});// After each Render trial Instance
}