-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schedule bugfix for lastSchedule, airbnb-ish, logging, cleanup #170
Conversation
λ/10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nits. Good catch on the lastSchedule bug.
if you want to rebase on master and add this file in to the list of eslinted files, you can make sure it stays properly styled.
modules/schedule/index.js
Outdated
|
||
reply("Removed schedule by \"" + s.blame + "\" which runs \"" + s.command + "\"" ); | ||
reply(`Removed schedule by "${s.blame}" which runs "${s.command}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which ran
I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this tense is correct here. The flow is:
!schedule add "every weekday" "Hey!"
...
Hey!
...
Hey!
!schedule remove hash
Removed schedule by "brhoades" which runs "Hey!"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be correct to say either Removing ... which runs ...
or Removed ... which ran ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I didn't read the first part of the string? It should be removing... changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the most correct might be "which would have run".
Anyways, you're right, fine as is.
modules/schedule/index.js
Outdated
next = next.map(sched => new Moment(sched)); | ||
|
||
for (let i = 1; i <= numSamples; i++) { | ||
totalSeconds += parseInt(getDifference(next[i + 1], next[i]).format('s'), 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number.parseInt
is mildly preferred these days and behaviourally identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/schedule/index.js
Outdated
const writeSchedule = (data) => { | ||
bot.writeDataFile('later.json', JSON.stringify(data), (err) => { | ||
if (err) { | ||
log.debug(`Error writing command file: ${err}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.error
I'd think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
modules/schedule/index.js
Outdated
|
||
const sortSchedules = scheds => ( | ||
Object.values(scheds).sort((a, b) => { | ||
if (a.created > b.created) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you can subtract moments and get a number, this can be simplified to:
sort((a, b) => a.created - b.created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/schedule/index.js
Outdated
var m = "Provided schedule query doesn't parse:\n"; | ||
var offset = 0; | ||
if (typeof(s) === 'number' || s.error >= 0) { | ||
let m = 'Provided schedule query doesn\'t parse:\n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backtick quotes to avoid the escaping thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint with airbnb throws a fit if you use backticks without any interpolation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of avoidEscape: true
here https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v16.1.0/packages/eslint-config-airbnb-base/rules/style.js#L391-L392, I think that you can actually use double-quotes here and still be on airbnb's good side.
2314698
to
2177ad8
Compare
Rebased, added schedule.js to lint script. |
Updated eslint targets, cleaned up schedule more. Updates from PR.
2177ad8
to
c42450b
Compare
let minimumCreationDelay = 0; | ||
let minimumInterval = 60; | ||
let noCommands = false; | ||
let digestLength = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious; why the digestLength change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back of the envelope math. I figured It's more likely schedule will break down due to performance issues before the threshold for a 1% collision chance.
Really: I got sick of testing and having to type out 8 letters ids to remove a schedule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally this one would have been 3 commits (bugfix, cleanup, rote-transformation-into-airbnb-style) to make it easier to review.
LGTM if you're happy with it
(To be clearer with what I meant, feel free to self-merge if you're happy with it @brhoades) |
…wobscale#170) Updated eslint targets, cleaned up schedule more. Updates from PR.
Bugfix for lastSchedule not caching properly (you could only ever have one schedule).
Now using log (part of #144).
General cleanup, made the file mildly airbnb styled.