LewisDaleUK / eleventy-plugin-bookwyrm

Fetch a Bookworm feed and add it to a collection for Eleventy
3 stars 0 forks source link

Results not appearing in global data #2

Closed freshyill closed 1 year ago

freshyill commented 1 year ago

Hi Lewis, I'm picking things up here from Mastodon. I've created a test repo https://github.com/freshyill/11ty-bookwyrm-test

I've stumbled onto some interesting results that might be helpful. The main issue is that fetching different users seems to produce different results. In all cases, even when it errors out, the cache files are filling up.

username freshyill

username mouse

[11ty] url is not defined (via ReferenceError)
[11ty] 
[11ty] Original error stack trace: ReferenceError: url is not defined
[11ty]     at getMessage (/Users/coleman/Sites/test/1/11ty-bookwyrm-test/node_modules/eleventy-plugin-bookwyrm/src/index.js:52:76)
[11ty]     at async Promise.all (index 6)
[11ty]     at async getFeed (/Users/coleman/Sites/test/1/11ty-bookwyrm-test/node_modules/eleventy-plugin-bookwyrm/src/index.js:66:24)
[11ty]     at async /Users/coleman/Sites/test/1/11ty-bookwyrm-test/node_modules/eleventy-plugin-bookwyrm/src/index.js:94:10
[11ty]     at async TemplateDataInitialGlobalData.getData (/Users/coleman/Sites/test/1/11ty-bookwyrm-test/node_modules/@11ty/eleventy/src/TemplateDataInitialGlobalData.js:24:25)
[11ty]     at async /Users/coleman/Sites/test/1/11ty-bookwyrm-test/node_modules/@11ty/eleventy/src/TemplateData.js:337:26
[11ty] File changed: eleventy.config.js

username TheReadingSeamstress

I was thinking that the size of the list might have affected things, but it seems like TheReadingSeamstress has more books than mouse, so I'm not sure that's the issue. Hopefully this helps. Please let me know if I can provide any more detail, or if you'd like me to try anything else.

freshyill commented 1 year ago

Tagging @lwojcik

lwojcik commented 1 year ago

I found the mistake 🤦 Will submit the fix shortly.

lwojcik commented 1 year ago

Okay, I submitted #3 and the plugin works fine formouse.

In case of freshyill account, the problem lies inside getFeed function - it performs a while loop and expects page.next attribute, but Chris' account returns only one page without a link to the next one.

Unless @LewisDaleUK is faster than me I'll address this too, but I need a little more time to give it proper testing.

LewisDaleUK commented 1 year ago

Good spot @lwojcik, thanks!

I've just pushed a new release out, I've tested v1.4.0 against a few different accounts and it seems to work well. Noticed you had a lot of reviews in your account Outbox, but not a lot of actual books - these wouldn't have shown up in the reading list at all. I've added support for reviews now. Each event attached to a book will have a type field of either Update or Review, e.g:

{
  "book": {
    "id": "https://bookwyrm.social/book/364566",
    "title": "Service Design: From Insight to Implementation",
    "authors": [
      "Andy Polaine"
    ],
    "description": "",
    "publishedDate": null,
    "cover": "https://bookwyrm-social.sfo3.digitaloceanspaces.com/images/covers/ed3d0dba-9542-4790-8b6a-0241e027e6e0.jpeg"
  },
  "events": [
    {
      "status": "rated Service Design: From Insight to Implementation: 4 stars",
      "date": "2023-05-28T00:00:00.000Z",
      "type": "Review"
    }
  ]
}
freshyill commented 1 year ago

@LewisDaleUK Sorry for the slow response again!

I suspect everything with the plugin is now working fine, but I guess I'm a little confused about what Bookwyrm puts into the outbox for the plugin to find. Is it only things that have a started and finished date? Things with a review? Things marked as read?

Almost all of this was pulled from my Goodreads account, which I never really kept up, where I just added things that I owned, both already-read and to-eventually-read.

I went into Bookwyrm and posted a few reviews, added start and finish dates, but I can't seem to get any existing books to make it into the eleventy data. I can't quite figure out which field to fill in or box to check to get these to show up. I'm half tempted to Right now, only four books end up in the global data. One that I just added, and three that I may have added before I ran the Goodreads import.

Any ideas? I'm half tempted to delete everything and just re-add them directly into Bookwyrm. I only have 56 books in there, so it's not like this would be a huge burden.