Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    NGTmeaty
    @NGTmeaty
    #198 should be it. :)
    Eric
    @SpyTec
    Left some comments
    NGTmeaty
    @NGTmeaty
    :thumbsup:
    NGTmeaty
    @NGTmeaty
    Do we have a good way to get objects of submissions other than just grabbing submissions? Wouldn't that only be one?
    Eric
    @SpyTec
    What do you mean?
    NGTmeaty
    @NGTmeaty
    (sorry, I am a bit tired, but) when you request a submission, it's an object. One submission, but if you get new posts for example, it's a Listing. Wouldn't passing something you already have to get it again be counterproductive?
    Eric
    @SpyTec
    Well, luckily snoowrap is a bit more intelligent than that. If your create a Submission object through snoowrap.getSubmission("1234") it won't fetch the submission right away. It will only fetch if your require something that isn't there yet (or use fetch())
    You do however get fullname with objects without requesting data
    NGTmeaty
    @NGTmeaty
    Hmm, I see what you mean. But wouldn't that still be a singular object with one submission?
    Eric
    @SpyTec
    Yeah, but you should send in an array to the function, so you'd call it using
    snoowrap.getContentByIds([snoowrap.getSubmission("1234"), snoowrap.getSubmission("5678")])
    NGTmeaty
    @NGTmeaty
    Aha! Alright. Will add that in tomorrow when I wake up :)
    Teddy Katz
    @not-an-aardvark
    Re. #196, that sounds good but I'm not sure how to make it so that one build only runs on master and another build runs on branches.
    Eric
    @SpyTec
    Gotcha, I was under the impression one could configure multiple TravisCI, though never done it
    Otherwise, I have no idea - would just be a nice QoL
    Eric
    @SpyTec
    Maybe GitHub actions can do it
    NGTmeaty
    @NGTmeaty
    Super close to having everything working, but a test to make sure it doesn't work with non fullname IDs, just isn't working at all. It's checking for it to throw a TypeError, but it throws the TypeError and fails. It works perfectly fine in other places in the code, but not here. Any ideas?
    Eric
    @SpyTec
    @NGTmeaty How do you write it?
    NGTmeaty
    @NGTmeaty
    expect(posts).to.throw(TypeError); throw new TypeError('Invalid argument: List of IDs need to be fullnames.');
    Eric
    @SpyTec
    You would need to change posts so it doesn't execute right away. Wrap it in a function
    const posts = () => await r.getContentByIds..
    Also, small thing, but could we rename the function to getContentByIds instead? Small d instead of capital :)
    NGTmeaty
    @NGTmeaty
    :thumbsup: Will give that a shot and change it :)
    Eric
    @SpyTec
    And when running the tests you don't need to run all of it, just need to run the ones you created
    NGTmeaty
    @NGTmeaty
    You can? 😮
    Eric
    @SpyTec
    npm run test -- --grep "name of with regex" the name can be describe too
    NGTmeaty
    @NGTmeaty
    Hmm, that seemed to just tell me it couldn't find any test files with that pattern? Regardless, got that fixed all up and it's working perfectly! All tests passing!
    Eric
    @SpyTec
    Cool
    NGTmeaty
    @NGTmeaty
    Should be all fixed up.
    Eric
    @SpyTec
    Added more comments. I think after that is addressed we can merge
    NGTmeaty
    @NGTmeaty
    :thumbsup: Will fix.
    Eric
    @SpyTec
    @not-an-aardvark if you have any concerns with the PR, let me know 🙂
    Eric
    @SpyTec
    @not-an-aardvark are you able to release tonight? When you do, ping me so I can deprecate DefinitelyTyped's definitions
    Teddy Katz
    @not-an-aardvark
    I'll do a release now, thanks for the ping
    Teddy Katz
    @not-an-aardvark
    @SpyTec Released
    Eric
    @SpyTec
    Thanks :)
    IK
    @ik30
    Hi not sure if this is the correct place (let me know, I'll delete the message) but I am new to all this and cannot figure out how to store the listing/object value from getSubreddit() into a JSON file. I'm getting the correct output when I use .then(console.log) but anything outside shows as undefined. Here is the code and output I am trying to store/export.
    (https://imgur.com/a/z0EBfwt)
    Eric
    @SpyTec

    So, you can either do it as

    getSubreddit().then(post => /** save to JSON here */);

    or

    const post = await getSubreddit();
     /** save to JSON here */

    To save to JSON, use JSON.stringify(). For saving to file, I believe you usefs

    @ik30
    IK
    @ik30
    @SpyTec Thanks for the reply. I have tried JSON Stringify before but I just get undefined as a result.
    I'll look into async/await not familiar with that. Maybe that's what is needed
    IK
    @ik30
    @SpyTec thanks for the help. I ended up just sending the terminal output to a text file.
    Eric
    @SpyTec
    The point is that you do it inside the then clause
    const fs = require('fs');
    getSubreddit().then(post => {
        let json = JSON.stringify(post)
        fs.writeFile("/tmp/test.json", json, function(err) {
            if(err) {
                return console.log(err);
            }
            console.log("The file was saved!");
        }); 
    })
    IK
    @ik30
    Thank you so much!! That worked for me!
    Jason Harrison
    @jasonharrison
    coming from python/praw, i am very happy with snoowrap =) excellent work
    Eric
    @SpyTec
    :D
    Eric
    @SpyTec
    @not-an-aardvark are my comments accurate in what needs to be done? In that since we don't get a listing from Reddit we have to manually use _transform to create the objects right? not-an-aardvark/snoowrap#209
    Eric
    @SpyTec
    Though, it would require a postListing to be created since it uses POST with data for query instead of GET with URL query params..
    Teddy Katz
    @not-an-aardvark
    I don't remember a lot of details but that sounds roughly correct. (I think getListing is just a helper method, so we wouldn't necessarily need to create a postListing method.)
    Eric
    @SpyTec
    I wonder if we can add a parameter to specify GET or POST in getListing.. I'll see about doing it without helper methods