Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new API endpoints for forums and topics #11742

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Sheppsu
Copy link
Contributor

@Sheppsu Sheppsu commented Dec 13, 2024

Closes #7440

It would be nice to have these available, and in my case, I want to automate some things on my otdb project by using the api to comb through the tournament forum. I would love to at least have the topic listing endpoint available if not the others.

Adds three endpoints:

  • Get a list of top-level forums and their subforums (max 2 deep)
  • Get a single forum with pinned topics and recent topics
  • Get a sorted list of topics optionally under a certain forum

implements 3 endpoints: forum listing, single forum by id with topics, and topic listing
app/Transformers/Forum/ForumTransformer.php Outdated Show resolved Hide resolved
app/Transformers/Forum/ForumTransformer.php Outdated Show resolved Hide resolved
app/helpers.php Outdated Show resolved Hide resolved
app/helpers.php Outdated Show resolved Hide resolved
app/Http/Controllers/Forum/ForumsController.php Outdated Show resolved Hide resolved
app/Http/Controllers/Forum/TopicsController.php Outdated Show resolved Hide resolved
app/Http/Controllers/Forum/ForumsController.php Outdated Show resolved Hide resolved
if (is_api_request()) {
return [
'forums' => json_collection($forums, new ForumTransformer(), ['subforums.subforums']),
'last_topics' => json_collection($lastTopics, new TopicTransformer()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another one here. and maybe move the last topics query after this (and for the other one as well)


return [
'forum' => json_item($forum, new ForumTransformer(), ['subforums.subforums']),
'topics' => json_collection($topics, new TopicTransformer()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a ->get() here (or above, or combined here)

'new' => [
// type 'timestamp' because the values are stored as integer in the database
['column' => 'topic_last_post_time', 'order' => 'DESC', 'type' => 'timestamp'],
['column' => 'topic_last_post_id', 'order' => 'DESC'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this destroys performance due to no usable index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add API route to get topic listing on a forum
2 participants