iangreenleaf / node-tumblrbot

Hubot-compatible Tumblr API wrapper for Node.js
7 stars 1 forks source link

Question about random photo pick #1

Closed zettam closed 9 years ago

zettam commented 9 years ago

What is the logic behind the random photo pick?

if I had 2 photo posts in total 100000 posts, would it still be able to return me a random photo? if so, how?

thank you.

iangreenleaf commented 9 years ago

That should work, yes. Tumblr provides the total number of posts of a given type, and we take a random number within that range and make a request using that number as the offset (i.e. asking Tumblr to return us the post at that position). So it should work regardless of the number of posts available.

zettam commented 9 years ago

Thank you very much!