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

Select Leetcode Problems #4

Open
ncharchenko opened this issue Jan 30, 2023 · 5 comments
Open

Select Leetcode Problems #4

ncharchenko opened this issue Jan 30, 2023 · 5 comments
Labels
extension A label for the LeetRooms web extension code server A label for the LeetRooms server code

Comments

@ncharchenko
Copy link

For right now, it appears that the plugin only gives a random set of problems. Being able to choose a set of problems for the room would be helpful for practice.

@marwanhawari marwanhawari added extension A label for the LeetRooms web extension code server A label for the LeetRooms server code labels Jan 31, 2023
@marwanhawari
Copy link
Owner

marwanhawari commented Jan 31, 2023

This is a big feature. Going to need a few things:

  • new UI element (probably a modal element in the Home.tsx component) to select the question filters
  • new logic in the extension to POST to the backend with that information
  • new logic in the "createRoom" handler on the backend to properly filter questions
  • updates to the db to allow for filtering

In my mind, there are more important features that I want to have first (which I've created issues for), so I'm probably not going to be working on this right away. But if somebody wants to start designing and coding this, I'd be happy to give feedback and review PRs.

On the UI, users should be able to filter by:

  1. Topics (including difficulty) - searchable and select-/unselect-all
  2. Contests (both weekly and biweekly)
  3. Problems (up to 4) - searchable and select-/unselect-all

Need db migration to add "Contest" and "Tags" (TEXT[]) columns to Questions table.

Will need a CRON job to update the Questions table when the contest questions are released.

@marwanhawari
Copy link
Owner

Partially solved by this PR:

Still need to add a difficulty filter for the topics.

I'm going to hold off on the contests/problems selection. I don't think it's high priority.

@jakecastelli
Copy link

Hi guys,

First of all, big shout out to @marwanhawari for making the extension, it makes solving leetcode with friends so much fun.

Second, I really like this purposed feature, my mate and I usually practice together 1 - 2 specific questions at night.

Is it ok for me to continue contributing to this feature?

Cheers

@marwanhawari
Copy link
Owner

Awesome, contributions are welcome! Here's a rough idea of what needs to be done to let users select specific questions:

  • Frontend:
    • add a new tab to the modal UI called Questions. Start here:
    • when the user switches to the Questions UI, fetch all the questions from the db (you'll need to create a new GET /questions/ endpoint). Use react query like in scoreboard modal:
      } = useQuery<PlayerWithSubmissions[]>({
    • Display a list of all the questions (don't worry about displaying difficulties). It should be selectable just like topics. Users should only be able to select a max of 4 questions.
      • there's potentially a lot of depth here like allowing the user to filter by difficulty, making it searchable, etc. but for now you can essentially just copy the way it's done w/ topics. Just needs a reset button to unselect all questions.
    • Add a new field to the QuestionFilterKind enum called Questions. Actually you need to do this in both the backend and frontend.
      export enum QuestionFilterKind {

      export enum QuestionFilterKind {
      • Make sure that when the app POSTs to the /rooms/ endpoint you set the questionFilter.kind to Questions the
let body: RoomSettings = {
    questionFilter: {
      kind: QuestionFilterKind.Questions
	  selections: [ { id: 1, title: "Two Sum", titleSlug: "two-sum", difficulty: Difficulty.Easy } ]
    };
    duration?: ...;
    difficulty: ...;
}
  • Backend:
    • add a new GET /questions/ endpoint. You'd need to make a new server/src/api/questions folder to put the files in.
    • Update the backend logic to handle when the filterKind is Questions:
      • You might find it easier to do a little refactoring here. Side note: the API as a whole is a bit of a mess right now and I'm planning to do a big refactor in the next few months.
        if (filterKind !== QuestionFilterKind.Topics) {

I might be missing something, but I just brain-dumped this and that's all I can think of for now. Of course, this is a lot and I don't expect you to do all of this (unless you want to).

Also, the best way to get a hold of me if you have questions is in the LeetRooms discord: https://discord.gg/bJBDNpSUWQ

@jakecastelli
Copy link

I really appreciate your step to step guide! This is absolutely amazing along with the CONTRIBUTION.md as my initial onboarding docs.

I like your idea and I will keep you updated on the progress either here or in discord:

there's potentially a lot of depth here like allowing the user to filter by difficulty, making it searchable, etc. but for now you can essentially just copy the way it's done w/ topics. Just needs a reset button to unselect all questions.

jakecastelli added a commit to jakecastelli/LeetRooms that referenced this issue Jul 7, 2023
Added Questions to QuestionFilterKind, if the filterKind is Questions, the
selections will be an array of title-slug, first we need to find the questions
by slug, the rest are remaining the same, basically a copy and paste from the
exisiting "Topics" logic, potentially should be refactored.

Added question router and two endpoints, one for search a specific question by
search term, the other one will randomly return 10 questions for the user to
pick.

Fixes: marwanhawari#4
jakecastelli added a commit to jakecastelli/LeetRooms that referenced this issue Jul 7, 2023
Added a new Tab called Questions, added search functionality which is server
side search, each time the server will return the most relevant 5 results.

If the user chooses Questions over Topics, then the question title slug will be
saved into `RoomSetting.questionFilter.selections`.

Added questions type to QuestionFilter in order to display the questions again
when setting modal is reopened.

The user can max select 4 questions, which is the same as current behaviour.

Fixes: marwanhawari#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension A label for the LeetRooms web extension code server A label for the LeetRooms server code
Projects
None yet
Development

No branches or pull requests

3 participants