not-an-aardvark / snoowrap

A JavaScript wrapper for the reddit API
MIT License
1.01k stars 127 forks source link

getSubredit.search({time:'hour',sort:'top'}) method return items by last day. #102

Open Sabutobi opened 7 years ago

Sabutobi commented 7 years ago

Is this correct behavior? Expected: get top rated reddit Posts via snoowrap by last hour. Actual: received top rated Post by 24 hours. See my code below:

const snoowrap = require('snoowrap');

module.exports = new snoowrap({
  userAgent: 'someAgent',
  clientId: 'somecorrectID',
  clientSecret: 'somecorrectSecret',
  refreshToken: 'somecorrectToken',
  scope: 'account creddits edit flair history identity modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread'
});
reddit.getMyMultireddits().then(data => {
            const subreddits = data[0].subreddits.map(sub => sub.display_name).join('+');
            config.getSubreddit(subreddits).search({
            query: req.body.query,
            time: 'hour',
            sort: 'top', limit: 5
            }).then(data => {
            categorizePost.categorize(data);
            firstSubreddits = data;
            res.json(data);
            });

I have gathered all subreddits into string. Then selected options: time: hour, sort: top.

Maybe I have done something wrong or snoowrap app has some different solutions for this task? Thanks for attention to me. Have a nice day.

not-an-aardvark commented 7 years ago

Could you run r.config({ debug: true }) and let me know what gets printed when you run that code?

Sabutobi commented 7 years ago

Hi! For example I've used word "Trump". Output of debug snoowrap below:

[debug] Received a 200 status code from agetrequest sent to https://oauth.reddit.com/r/MarchAgainstTrump+live+FirstLook+SandersForPresident+NYTauto+economy+CBSauto+newsbot+USNEWS+worldevents+GLOBEauto+MiddleEastNews+TheTwitterFeed+LATIMESauto+NASAauto+DAINIKJAGRANauto+technology+NPRauto+humanrights+ESPNauto+business+TechNewsToday+internationalbusiness+FOLHAauto+NeutralPolitics+LegalNews+entertainment+CHICAGOTRIBauto+Insidernews+newsbotbot+worldnews+NewsYouShouldKnow+finance+willis7737_news+inthenews+nyc+PCauto+UpliftingNews+Economics+CHICAGOSUNauto+DESERETauto+TropicalWeather+HTauto+POTUSWatch+qualitynews+NROauto+globalhealth+NYPOSTauto+TheNewsFeed+Intercept+news+ARABIYAauto+PHILLYauto+boston+OREGONIANauto+EnoughTrumpSpam+HAWAIITHauto+HONOLULUSAauto+de+TETauto+JUNEAUauto+london+elonmusk+FRANCE24auto+JustNews+autotldr+BANGKOKPOSTauto+Austria+IOLauto+CHINADAILYauto+PGHTRIBauto+PEOPLESDAILYauto+energy+NSALeaks+theworldnews+syriancivilwar+IRISHTIMESauto+InternationalNews+uspolitics+UMukhasimAutoNews+internationalpolitics+moderatepolitics+asia+ANSAauto+NorthKoreaNews+worldpolitics+INDEPENDENTauto+geopolitics+FOXauto+NDTVauto+CNNauto/search?raw_json=1&count=9999&sort=top&limit=5&subreddit=MarchAgainstTrump%2Blive%2BFirstLook%2BSandersForPresident%2BNYTauto%2Beconomy%2BCBSauto%2Bnewsbot%2BUSNEWS%2Bworldevents%2BGLOBEauto%2BMiddleEastNews%2BTheTwitterFeed%2BLATIMESauto%2BNASAauto%2BDAINIKJAGRANauto%2Btechnology%2BNPRauto%2Bhumanrights%2BESPNauto%2Bbusiness%2BTechNewsToday%2Binternationalbusiness%2BFOLHAauto%2BNeutralPolitics%2BLegalNews%2Bentertainment%2BCHICAGOTRIBauto%2BInsidernews%2Bnewsbotbot%2Bworldnews%2BNewsYouShouldKnow%2Bfinance%2Bwillis7737_news%2Binthenews%2Bnyc%2BPCauto%2BUpliftingNews%2BEconomics%2BCHICAGOSUNauto%2BDESERETauto%2BTropicalWeather%2BHTauto%2BPOTUSWatch%2Bqualitynews%2BNROauto%2Bglobalhealth%2BNYPOSTauto%2BTheNewsFeed%2BIntercept%2Bnews%2BARABIYAauto%2BPHILLYauto%2Bboston%2BOREGONIANauto%2BEnoughTrumpSpam%2BHAWAIITHauto%2BHONOLULUSAauto%2Bde%2BTETauto%2BJUNEAUauto%2Blondon%2Belonmusk%2BFRANCE24auto%2BJustNews%2Bautotldr%2BBANGKOKPOSTauto%2BAustria%2BIOLauto%2BCHINADAILYauto%2BPGHTRIBauto%2BPEOPLESDAILYauto%2Benergy%2BNSALeaks%2Btheworldnews%2Bsyriancivilwar%2BIRISHTIMESauto%2BInternationalNews%2Buspolitics%2BUMukhasimAutoNews%2Binternationalpolitics%2Bmoderatepolitics%2Basia%2BANSAauto%2BNorthKoreaNews%2Bworldpolitics%2BINDEPENDENTauto%2Bgeopolitics%2BFOXauto%2BNDTVauto%2BCNNauto&restrictSr=true&syntax=plain&t=hour&q=Trump&restrict_sr=true. ratelimitRemaining: 596

Thanks for attention to my issue.