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

Language queries don't work yet #18

Open
j127 opened this issue Dec 8, 2020 · 2 comments
Open

Language queries don't work yet #18

j127 opened this issue Dec 8, 2020 · 2 comments

Comments

@j127
Copy link
Member

j127 commented Dec 8, 2020

When querying on Slack for CW puzzles, languages aren't taken into account in the Django queries.

The q query will be a dictionary with a languages key that holds a Python list. The structure is like this:

{'languages': ['fortran', 'cobol', 'raku'], 'source': 'codewars', 'difficulty': 3}

The relevant data is stored as JSONB in Postgres. An example raw SQL query is:

SELECT original_raw_data ->> 'languages'
FROM puzzles_puzzle
WHERE source='Codewars'
LIMIT 1;
-- ["javascript", "haskell", "python", "rust"]

The Django query should return a puzzle that includes all of the languages that in listed in the q query.

See the notes that will be in apps/puzzles/puzzles.py.

@j127
Copy link
Member Author

j127 commented Dec 12, 2020

Check out 9:20 in this video for how to do queries on JSON fields:
https://www.youtube.com/watch?v=LbdUpY1I1zg

@j127
Copy link
Member Author

j127 commented Dec 12, 2020

If it requires raw queries, this SO answer might help:
https://dba.stackexchange.com/a/162595

@j127 j127 added possibly outdated These are old issues that might be out of date and removed possibly outdated These are old issues that might be out of date labels Apr 10, 2022
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

No branches or pull requests

1 participant