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

Filter exercises in the backend #2676

Open
flacial opened this issue Jan 9, 2023 · 2 comments
Open

Filter exercises in the backend #2676

flacial opened this issue Jan 9, 2023 · 2 comments
Labels
perf Performance related issues

Comments

@flacial
Copy link
Member

flacial commented Jan 9, 2023

Problem

All the exercises are sent to the frontend and only a portion is rendered for the user. This does not only impact the performance on mobile devices, but also waste the user bandwidth.

Steps to reproduce

  1. Sign in with admin user and go to /exercises/js0
  2. Go to /curriculum/js0/mentor and remove an exercise
  3. Go to /exercises/js0 and inspect the getExercises query request
  4. Notice how it has all the exercises even the removed one

Expected behavior

Backend should only send exercises that are not removed and are for the current lesson. If the user is taking the exercises of JS1, it should send the exercises for JS1

Actual behavior

Backend sends all the exercises to the client (All lessons exercises & removed exercises)

@flacial flacial added the perf Performance related issues label Jan 9, 2023
@flacial flacial moved this to 📋 Backlog in C0D3-APP Team Sprints Jan 9, 2023
@flacial flacial moved this from 📋 Backlog to 🆕 New in C0D3-APP Team Sprints Jan 9, 2023
@kondanna
Copy link
Collaborator

kondanna commented Feb 7, 2023

I looked into this issue and it looks like each exercise has a removedAt flag (of type timestamp) in the database.

We could keep this functionality as-is or have the remove exercise function outright delete the exercise from the database (and eliminate the removedAt column).

const currentExercises = exercises
    .filter(
      exercise =>
        exercise.module.lesson.slug === slug &&
        exercise.author.id === sessionUser?.id &&
        !exercise.removedAt
    )
    .map(exercise => ({
      id: exercise.id,
      moduleName: exercise.module.name,
      problem: exercise.description,
      answer: exercise.answer,
      explanation: exercise.explanation || ''
    }))
    
    return ...

@kondanna
Copy link
Collaborator

kondanna commented Feb 7, 2023

The functions are under /graphql/resolvers/exerciseCrud.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Performance related issues
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants