Compare commits
No commits in common. "c5390c3909d31536823d324af1d92c94bcd7cd17" and "f3dfd6f4848304ff9e65f5646fbe9fc2bc882fbb" have entirely different histories.
c5390c3909
...
f3dfd6f484
2 changed files with 10 additions and 19 deletions
15
api/app.js
15
api/app.js
|
@ -15,7 +15,7 @@ const token = process.env.SLACK_BOT_TOKEN;
|
||||||
const channel = process.env.SLACK_MILLION_CHANNEL;
|
const channel = process.env.SLACK_MILLION_CHANNEL;
|
||||||
const port = process.env.PORT ?? 3000;
|
const port = process.env.PORT ?? 3000;
|
||||||
|
|
||||||
const goalDate = '10/1/2024';
|
const goalDate = '3/1/2024';
|
||||||
const goalNumber = 300000;
|
const goalNumber = 300000;
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
|
@ -24,7 +24,7 @@ const app = new App({
|
||||||
});
|
});
|
||||||
|
|
||||||
function extractNumber(txt) {
|
function extractNumber(txt) {
|
||||||
let array = ["-", " ", "\n"]
|
let array = ["\n", " ", "-"]
|
||||||
for (let i of array) {
|
for (let i of array) {
|
||||||
if (txt.includes(i)) {
|
if (txt.includes(i)) {
|
||||||
return txt.split(i)[0]
|
return txt.split(i)[0]
|
||||||
|
@ -173,14 +173,9 @@ async function report() {
|
||||||
function predictSpeed(goalDate, goalNumber, currentNumber) {
|
function predictSpeed(goalDate, goalNumber, currentNumber) {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let goal = new Date(goalDate);
|
let goal = new Date(goalDate);
|
||||||
let timeRemaining = goal - today;
|
let timeRemaining = Math.abs(goal - today);
|
||||||
let daysRemaining
|
let daysRemaining = Math.ceil(timeRemaining / (1000 * 60 * 60 * 24));
|
||||||
if (timeRemaining >= 0) {
|
let neededSpeed = (goalNumber - currentNumber) / daysRemaining;
|
||||||
daysRemaining = Math.ceil(timeRemaining / (1000 * 60 * 60 * 24));
|
|
||||||
else {
|
|
||||||
daysRemaining = math.floor(timeRemaining / (1000 * 60 * 60 * 24));
|
|
||||||
}
|
|
||||||
let neededSpeed = (goalNumber - currentNumber) / Math.abs(daysRemaining);
|
|
||||||
return [daysRemaining, neededSpeed];
|
return [daysRemaining, neededSpeed];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,12 @@ function addQuotes(message, rawGoals, rawSpeed) {
|
||||||
let diff = goals - speed;
|
let diff = goals - speed;
|
||||||
if (goals <= 0) {
|
if (goals <= 0) {
|
||||||
end = `:tada: YOU DID IT, MY LOYAL SERVANTS! YOU'VE REACHED OUR GOAL ON TIME! :tada: But there's still loads of time before we reach a million-- let's keep up the pace!`
|
end = `:tada: YOU DID IT, MY LOYAL SERVANTS! YOU'VE REACHED OUR GOAL ON TIME! :tada: But there's still loads of time before we reach a million-- let's keep up the pace!`
|
||||||
} else if (diff < 10 && days > 0) {
|
} else if (diff < 10) {
|
||||||
end = `You're doing well, my lackeys! Keep up that speed of at least *+${speed}* if you want to reach that goal! You have *${days}* days remaining to get there!`
|
end = `You're doing well, my lackeys! Keep up that speed of at least *+${speed}* if you want to reach that goal! You have *${days}* days remaining to get there!`
|
||||||
} else if (diff > 10 && diff < 1000 && days > 0) {
|
} else if (diff > 10 && diff < 1000) {
|
||||||
end = `Still room to improve your performance, my underlings-- you're only at *${speed}* a day! Get that speed up to at least *+${goals}* to get there on time! You have *${days}* days left!`
|
end = `Still room to improve your performance, my underlings-- you're only at *${speed}* a day! Get that speed up to at least *+${goals}* to get there on time! You have *${days}* days left!`
|
||||||
} else if (diff > 1000 && days > 0) {
|
} else if (diff > 1000) {
|
||||||
end = `You're slogging behind, my minions! Only *${speed}* a day? RiDONKulous! Get that speed up to at least *+${goals}* to get there on time! Hurry up!!! You have *${days}* days left to get there!`
|
end = `You're slogging behind, my minions! Only *${speed}* a day? RiDONKulous! Get that speed up to at least *+${goals}* to get there on time! Hurry up!!! You have *${days}* days left to get there!`
|
||||||
} else if (days == 0) {
|
|
||||||
end = `Today's the deadline my minions! I hope you can count at least *+${goals}* today, otherwise we'll miss the deadline!`
|
|
||||||
} else if (days < 0) {
|
|
||||||
end = `We've missed the deadline by ${Math.abs(days)} day${(days < -1)? 's': ''} my underlings-- I hope you can make the next one. In the meantime, I recommend counting *+${goals}* numbers today.`
|
|
||||||
}
|
}
|
||||||
return start + "\n" + message + "\n" + end;
|
return start + "\n" + message + "\n" + end;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue