seebruecke-org / frontend

Frontend application for the Seebruecke movement.
https://seebruecke.org
3 stars 2 forks source link

machine-readable access to list of actions #93

Closed derhuerst closed 1 year ago

derhuerst commented 2 years ago

Hey! 👋

I maintain seebruecke-events-calendar-feed, a dynamically generated iCalendar feed that people can subscribe to in their personal calendar apps, allowing them to notice Seebrücke actions without opening the website.

It seems like the website has been rebuilt, and is now a Next.js app, so the calendar feed currently fails to extract the list of actions.

Is there a way to obtain the list of actions in a machine-readable way, under a stable URL? I could only find https://seebruecke.org/_next/data/xi2YC3KuSjTC7rxlWTUM3/de/actions.json, but it seems like this URL contains a build ID or something similar and will therefore break soon.

If there is no such API, can we add it? If you give me a hint on how to approach this, I'll happily submit a PR.

Alternatively, is there a way to obtain a completely static, server-side-rendered version of the page, so that I can continue scraping the actions from the HTML?

derhuerst commented 1 year ago

have you had a chance to look at this? 🙂

apriljunge commented 1 year ago

There is a graphql endpoint at https://api.seebruecke.org/graphql. You can query for actions to get all the information you need (title, start, end, location, slug, …).

derhuerst commented 1 year ago

How do the sort and where arguments of the actions()field work? The GraphQL schema just saysStringandJSON`, respectively.

Ideally, I want to sort actions by start date, descending, and only find actions whose start date is >= (today - 30 days).

apriljunge commented 1 year ago

I found a code snippet in this repo where they filter actions by date. I think they're using the strapi graphql plugin. Based on this documentation I built this and it worked.

You can use start_lt (lower than) or start_lte (lower than equals). I think for your case it makes not difference. Instead of filtering by start you could also use limit.

query {
  actions (
    sort: "start:asc",
    where: {
      start_lt: "2022-12-18T00:00:00.000Z",
      end_gt: "2022-12-17T00:00:00.000Z",
    }
  )
  {
    id,
    title,
    start,
    end,
    location,
    location_detail,
    slug,
  }
}
derhuerst commented 1 year ago

Thanks for the hint!

I noticed that the actions currently don't have a link, even though the website has a page for each action:

{
    action(id: "841") {
        link
    }
}
{
    "data": {
        "action": {
            "link": null
        }
    }
}

Reclaim the Hinterland action page

Do you know why @Halifax @azinazadi?

azinazadi commented 1 year ago

What I can tell from looking into the DB is that the link points to an external link for some actions grafik

azinazadi commented 1 year ago

To make the url in SB website you could use the slug ( https://www.seebruecke.org/aktionen/{slug} ). Soon will come also the english website, but the german urls wouldn't be affected...

Is there anything I can help still?

derhuerst commented 1 year ago

Is there anything I can help still?

Having the group's and/or city's timezone specifier (e.g. Europe/Helsinki) would be great! Currently, I assume Europe/Berlin for all actions.

derhuerst commented 1 year ago

The following query is currently extremely slow (~60s):

Edit: now it is faster (~1s), nevermind

query recentActions ($start_gte: String!) {
  actions(
    sort: "start:desc"
    where: {
      start_gte: $start_gte
    }
    limit: 5

    ) {
    id
    slug
    updated_at
    locale
    title
    start, end
    location, location_detail
    coordinates
    link
    group {
      localizations {
        content {
          ...on ComponentSharedBlocksContact {
            __typename
            email
          }
        }
      }
      city {
        name
        slug
        federal_country {
          slug
          country {
            slug
          }
        }
      }
    }
  }
}
{
  "start_gte": "2022-12-12T12:12Z"
}
azinazadi commented 1 year ago

ok great to see it working. about time zone, the time of the actions refer to the local time that it takes place. We also store the coordinations where the event takes place and the city:

grafik

maybe they could be used to automatically detect the timzone...

apriljunge commented 1 year ago

Having the group's and/or city's timezone specifier (e.g. Europe/Helsinki) would be great! Currently, I assume Europe/Berlin for all actions.

In this repository the timezone is also fixed to Europe/Berlin. That is definitely not ideal. As long as this is not handled differently in the Seebrücke frontend, I think you should also keep it static to avoid possible deviations.

Maybe we should create a new issue for this?

https://github.com/seebruecke-org/frontend/blob/38e8c603769d9ee7bc52fa2bcef41db765406bfa/lib/actions.js#L15

derhuerst commented 1 year ago

I'm closing this, as the access to the API works for me. Thanks.