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

Garage pubsub alert #23

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

hoppermeister
Copy link
Collaborator

No description provided.

Copy link
Owner

@SammyIsra SammyIsra left a 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);
Copy link
Owner

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())
Copy link
Owner

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()
Copy link
Owner

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

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.

2 participants