Heeft Discourse een interface om direct de laatste reactie van een bericht te krijgen?

AI-generated summary

McDonald_Louise seeked an API to retrieve the last comment of a specific topic in Discourse without specifying the post number. MachineScholar suggested using a Data Explorer query with SQL parameters to fetch the post details programmatically. McDonald_Louise clarified that the requirement was for an API integration between two different services. MachineScholar offered to write a Python script if more context was provided. NateDhaliwal pointed out that Data Explorer queries can be executed via the Discourse API. McDonald_Louise confirmed the issue was resolved and, upon request from NateDhaliwal, explained the solution: performing two API calls, first to get the total comment count and then to retrieve the last comment based on that count.

Ik heb een discourse nodig die rechtstreeks de laatste reactie op een bericht kan ophalen, alleen met het bericht-ID, zonder de reactie-ID op te geven, om de laatste reactie direct op te halen. Is er zo’n interface?

Ik zou een query van een data-explorer aanbevelen. Je kunt query’s programmatisch uitvoeren en JSON-resultaten krijgen. Hier is het:

-- [params]
-- post_id :post_id

SELECT
  p.id,
  p.topic_id,
  p.post_number,
  p.raw    AS raw_content,   -- Markdown/bron
  p.cooked AS html_content,  -- Gerenderde HTML
  p.user_id,
  p.created_at,
  p.updated_at
FROM posts p
WHERE p.id = :post_id
  AND p.deleted_at IS NULL   -- verwijder dit als je ook verwijderde berichten wilt
-- AND p.hidden = false      -- sluit optioneel verborgen berichten uit
LIMIT 1;

Het zijn twee verschillende services, die alleen via een interface kunnen worden verkregen.

Maybe you could explain a little bit more what you’re trying to achieve? Then I could make you a Python script for example :smiling_face:

You can create the data explorer query, then call it using the API.

Bedankt allemaal, ik heb het inmiddels op een andere manier opgelost.

Vindt u het erg om te delen hoe u het heeft opgelost? Het zou anderen met dezelfde vraag kunnen helpen.

It is done through two interface calls, one to get the total number of comments and then use that number to get the last one.