Skip to content
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

Merged
merged 2 commits into from
Nov 22, 2017

Conversation

brhoades
Copy link
Collaborator

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.

@LinuxMercedes
Copy link
Member

λ/10

Copy link
Member

@euank euank left a 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.


reply("Removed schedule by \"" + s.blame + "\" which runs \"" + s.command + "\"" );
reply(`Removed schedule by "${s.blame}" which runs "${s.command}"`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which ran I think?

Copy link
Collaborator Author

@brhoades brhoades Nov 19, 2017

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!"

Copy link
Member

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 ....

Copy link
Collaborator Author

@brhoades brhoades Nov 19, 2017

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.

Copy link
Member

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.

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);
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const writeSchedule = (data) => {
bot.writeDataFile('later.json', JSON.stringify(data), (err) => {
if (err) {
log.debug(`Error writing command file: ${err}`);
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep


const sortSchedules = scheds => (
Object.values(scheds).sort((a, b) => {
if (a.created > b.created) {
Copy link
Member

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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';
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

@euank euank Nov 19, 2017

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.

@brhoades
Copy link
Collaborator Author

Rebased, added schedule.js to lint script.

Updated eslint targets, cleaned up schedule more.

Updates from PR.
let minimumCreationDelay = 0;
let minimumInterval = 60;
let noCommands = false;
let digestLength = 4;
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

@euank euank left a 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

@euank
Copy link
Member

euank commented Nov 22, 2017

(To be clearer with what I meant, feel free to self-merge if you're happy with it @brhoades)

@brhoades brhoades merged commit a595e48 into wobscale:master Nov 22, 2017
@brhoades brhoades deleted the schedule-update branch November 22, 2017 20:19
gmackie pushed a commit to gmackie/EuIrcBot that referenced this pull request Dec 16, 2017
…wobscale#170)

Updated eslint targets, cleaned up schedule more.

Updates from PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants