-
Notifications
You must be signed in to change notification settings - Fork 2
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
Garage pubsub alert #23
base: master
Are you sure you want to change the base?
Conversation
…ster' into SammyIsra/master
Add a node if pubsubs are on sale that day (but only check once a day)
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.
One thing that I should be changed definitely is the "random" part. My guess is that it is a breaking issue because one will always try to get json[undefined]
which in turn returns undefined
.
From the other two, one is mostly an opinion and another one a thought for the future.
msg.send( (JSON.parse(body).data.children)[Math.floor(Math.random()*(JSON.parse(body).data.children).length)].data.url); | ||
var json = JSON.parse(body).data.children; | ||
|
||
msg.send( json[random].data.url); |
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 don't think random
exists here. You set it in a for
loop in a different function (line 39), on a scope we don't have access to here.
|
||
|
||
if robot.brain.get('pubsubCheckDate') isnt (new Date()).toDateString() | ||
robot.brain.set('pubsubCheckDate', (new Date()).toDateString()) |
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.
This is more a matter of opinion, but wouldn't it be better to assign today's date to a variable instead of calling (new Date()).toDateString()
twice? It's not a performance thing tho, more a readability thing.
|
||
|
||
|
||
if robot.brain.get('pubsubCheckDate') isnt (new Date()).toDateString() |
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 now we have two different places where we do the same thing (get pubsub stuff) it would probably be best to have a function somewhere else that is used both here and in scripts/pubsub.js.
Buuut we may want to hold off this specific change until we deal with #24
No description provided.