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

Backend information to fetch smarter resources filters #710

Open
Bluenix2 opened this issue Apr 3, 2022 · 8 comments · May be fixed by #1166
Open

Backend information to fetch smarter resources filters #710

Bluenix2 opened this issue Apr 3, 2022 · 8 comments · May be fixed by #1166
Assignees
Labels
status: WIP Work In Progress type: enhancement Changes or improvements to existing features

Comments

@Bluenix2
Copy link
Member

Bluenix2 commented Apr 3, 2022

Summary

Following python-discord/bot#2079 it was discussed having an API allowing the bot to fetch possible filters so that implementations don't need to scrape it.

This new API could power different future bot features like having interaction-based URL builder.

Description

Currently resources are loaded from a folder of yml, then a number of different steps in processing are applied to sort out all filters and its topics. This is a highly dynamic system which will complicate this PR.

The API resides in pydis_site/apps/api whilst the resources is in its own app at pydis_site/apps/resources (the actual view is in pydis_site/apps/resources/views/resources.py) which complicates things. See, for the API backend to get access to that information there needs to be an import there or loading - which might be unwanted.

This means that the implementation might be a bit more complicated than one might first think. The easiest way to go about this would be placing the route under resources but it is still, technically, part of the API. Another option would be duplicating the processing, inside of API, but that still requires access to the folder of resources meaning that we are back at square one of having unwanted coupling.

Assignee

@iamericfletcher has asked to implement this (I couldn't assign them directly). Please note that this is still in planning.

@Bluenix2 Bluenix2 added status: planning Discussing details type: enhancement Changes or improvements to existing features labels Apr 3, 2022
@iamericfletcher
Copy link
Contributor

iamericfletcher commented Apr 5, 2022

I don't have much to contribute to the discussion since I'm still relatively new to programming. I'd rather use this opportunity to absorb what I can from those with more experience. Still, I find the API interaction with bot and vice-versa fascinating and am excited to take on this issue if approved!

@PLAZMAMA
Copy link

Since I am new to open source and am looking for my first contrib. I would like to try to tackle this issue with another willing person.

@imbhaskarn
Copy link

Is the issue still open?

@PLAZMAMA
Copy link

PLAZMAMA commented Dec 3, 2022

I don't know to be honest, I only see that its still open here.

@jchristgit
Copy link
Member

@Bluenix2 just so I understand it correctly: is this about having an endpoint that exposes the query parameter filtering support of site endpoints?

@jchristgit
Copy link
Member

Ok, it seems I missed the mark. Is this about exposing the filters in this dictionary? https://github.com/python-discord/site/blob/main/pydis_site/apps/resources/views/resources.py#L68

@wookie184
Copy link
Contributor

Ok, it seems I missed the mark. Is this about exposing the filters in this dictionary? https://github.com/python-discord/site/blob/main/pydis_site/apps/resources/views/resources.py#L68

Yeah I think that's the idea.

Currently if the !resources command is given an argument e.g. !resources web development, the link will filter the topic by web development (links to https://www.pythondiscord.com/resources/?topics=web-development). This would potentially allow fuzzy matching for topics, or extending it to match on things other than topics (e.g. it could tell that !resources free wanted https://www.pythondiscord.com/resources/?payment-tiers=free).

If we want to do this it would probably be worth having a bot issue with a concrete use case for the endpoint first, so we don't add something we wont use, and we can ensure the endpoint includes what is needed. I somewhat question whether it's necessary, given the person can just filter what they once when they're on the page.

@mbaruh
Copy link
Member

mbaruh commented Apr 5, 2023

The resources command currently does no validation for the given argument. There is this new issue python-discord/bot#2510, which I think is very reasonable, but I would rather the bot didn't spit back arbitrary strings given by the user (both for the correctness of the provided URL and from a moderation perspective). I think that's already a solid use case for this feature.

@jchristgit jchristgit self-assigned this Dec 10, 2023
jchristgit added a commit that referenced this issue 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:

    {
      "filters": {
        "Difficulty": {
          "filters": [
            "Beginner",
            "Intermediate"
          ],
          "icon": "fas fa-brain",
          "hidden": false
        },
        "Type": {
          "filters": [
            "Book",
            "Community",
            "Course",
            "Interactive",
            "Podcast",
            "Project Ideas",
            "Tool",
            "Tutorial",
            "Video"
          ],
          "icon": "fas fa-photo-video",
          "hidden": false
        },
        "Payment tiers": {
          "filters": [
            "Free",
            "Paid",
            "Subscription"
          ],
          "icon": "fas fa-dollar-sign",
          "hidden": true
        },
        "Topics": {
          "filters": [
            "Algorithms and Data Structures",
            "Data Science",
            "Databases",
            "Discord Bots",
            "Game Development",
            "General",
            "Microcontrollers",
            "Security",
            "Software Design",
            "Testing",
            "Tooling",
            "User Interface",
            "Web Development",
            "Other"
          ],
          "icon": "fas fa-lightbulb",
          "hidden": true
        }
      },
      "valid_filters": {
        "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 jchristgit linked a pull request Dec 10, 2023 that will close this issue
@hedyhli hedyhli added status: WIP Work In Progress and removed status: planning Discussing details labels Feb 14, 2024
jchristgit added a commit that referenced this issue Jun 14, 2024
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:

    {
      "Difficulty": {
        "filters": [
          "Beginner",
          "Intermediate"
        ],
        "icon": "fas fa-brain",
        "hidden": false,
        "filter_slugs": [
          "beginner",
          "intermediate"
        ],
        "slug": "difficulty"
      },
      "Type": {
        "filters": [
          "Book",
          "Community",
          "Course",
          "Interactive",
          "Podcast",
          "Project Ideas",
          "Tool",
          "Tutorial",
          "Video"
        ],
        "icon": "fas fa-photo-video",
        "hidden": false,
        "filter_slugs": [
          "book",
          "community",
          "course",
          "interactive",
          "podcast",
          "project-ideas",
          "tool",
          "tutorial",
          "video"
        ],
        "slug": "type"
      },
      "Payment tiers": {
        "filters": [
          "Free",
          "Paid",
          "Subscription"
        ],
        "icon": "fas fa-dollar-sign",
        "hidden": true,
        "filter_slugs": [
          "free",
          "paid",
          "subscription"
        ],
        "slug": "payment-tiers"
      },
      "Topics": {
        "filters": [
          "Algorithms and Data Structures",
          "Data Science",
          "Databases",
          "Discord Bots",
          "Game Development",
          "General",
          "Microcontrollers",
          "Security",
          "Software Design",
          "Testing",
          "Tooling",
          "User Interface",
          "Web Development",
          "Other"
        ],
        "icon": "fas fa-lightbulb",
        "hidden": true,
        "filter_slugs": [
          "algorithms-and-data-structures",
          "data-science",
          "databases",
          "discord-bots",
          "game-development",
          "general",
          "microcontrollers",
          "security",
          "software-design",
          "testing",
          "tooling",
          "user-interface",
          "web-development",
          "other"
        ],
        "slug": "topics"
      }
    }

Closes #710.
jchristgit added a commit that referenced this issue Aug 2, 2024
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 added a commit that referenced this issue Aug 2, 2024
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 added a commit that referenced this issue Aug 2, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: WIP Work In Progress type: enhancement Changes or improvements to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants