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 endpoint to fetch filters in JSON format #1166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jchristgit
Copy link
Member

@jchristgit jchristgit commented Dec 10, 2023

While this is an API endpoint consumed by the bot, keep it in the
resources app instead of the api app, as all the logic and data for
resources is contained within the resources app and we don't want to
start messing around with that.

The response format from the endpoint is as follows:

{
    "topics": [
        "algorithms-and-data-structures",
        "data-science",
        "databases",
        "discord-bots",
        "game-development",
        "general",
        "microcontrollers",
        "security",
        "software-design",
        "testing",
        "tooling",
        "user-interface",
        "web-development",
        "other"
    ],
    "payment_tiers": [
        "free",
        "paid",
        "subscription"
    ],
    "type": [
        "book",
        "community",
        "course",
        "interactive",
        "podcast",
        "project-ideas",
        "tool",
        "tutorial",
        "video"
    ],
    "difficulty": [
        "beginner",
        "intermediate"
    ]
}

Closes #710.

Copy link

netlify bot commented Dec 10, 2023

Deploy Preview for pydis-static ready!

Name Link
🔨 Latest commit c63ab0b
🔍 Latest deploy log https://app.netlify.com/sites/pydis-static/deploys/66acd9bb1a208e00088dc1fe
😎 Deploy Preview https://deploy-preview-1166--pydis-static.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@coveralls
Copy link

coveralls commented Dec 10, 2023

Coverage Status

coverage: 100.0%. remained the same
when pulling c63ab0b on resource-filter-fetch
into e51d80a on main.

@jchristgit jchristgit added area: backend Related to internal functionality and utilities area: API Related to or causes API changes language: python Involves Python code type: feature New feature or request priority: 2 - normal Normal Priority labels Dec 10, 2023
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

The response format here doesn't seem ideal. My understanding is that "filters" is the display name, and "valid_filters" is what goes in the URL(?), but the response doesn't link these together.

We could link them together in the structure, along the lines of this:

[
    {
      "name": "Difficulty",
      "query_param": "difficulty",
      "options": [
        {"name": "Beginner", "query_value": "beginner"},
        ...
      ],
      "icon": "fas fa-brain",
      "hidden": false,
    },
    ...
]

Alternatively we could maybe just drop the "valid_filters" section and document the transformation to get from the name to the url.

@wookie184 wookie184 added the s: waiting for author Waiting for author to address a review or respond to a comment label May 24, 2024
@jchristgit
Copy link
Member Author

@wookie184 thanks for the review and sorry for the long delay. I've updated the response format, the "sluggified" / "kebabified" version of the names can now be found in the slug field for the respective category, and the filter_slugs field for each filter. To be specific, filter_slugs[3] == to_kebabcase(slugs[3]). Let me know what you think.

@jchristgit jchristgit removed the request for review from mbaruh June 20, 2024 15:23
@jchristgit jchristgit added s: needs review Author is waiting for someone to review and approve and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Jun 20, 2024
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

This seems to undo the fix for #1209, I think it will cause performance issues.

@jchristgit jchristgit force-pushed the resource-filter-fetch branch 2 times, most recently from 2c5c2dc to 7997f98 Compare August 2, 2024 13:03
While this is an API endpoint consumed by the bot, keep it in the
`resources` app instead of the `api` app, as all the logic and data for
resources is contained within the `resources` app and we don't want to
start messing around with that.

The response format from the endpoint is as follows:

    {
        "topics": [
            "algorithms-and-data-structures",
            "data-science",
            "databases",
            "discord-bots",
            "game-development",
            "general",
            "microcontrollers",
            "security",
            "software-design",
            "testing",
            "tooling",
            "user-interface",
            "web-development",
            "other"
        ],
        "payment_tiers": [
            "free",
            "paid",
            "subscription"
        ],
        "type": [
            "book",
            "community",
            "course",
            "interactive",
            "podcast",
            "project-ideas",
            "tool",
            "tutorial",
            "video"
        ],
        "difficulty": [
            "beginner",
            "intermediate"
        ]
    }

Closes #710.
@jchristgit
Copy link
Member Author

Looks like I managed to mess up during rebasing. It should all be fine now, and the code should be a lot simpler thanks to Rohan's changes. Please also see the new response file format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Related to or causes API changes area: backend Related to internal functionality and utilities language: python Involves Python code priority: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend information to fetch smarter resources filters
5 participants