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 schedule query to Graphql #56

Merged
merged 8 commits into from
Apr 11, 2021
Merged

Add schedule query to Graphql #56

merged 8 commits into from
Apr 11, 2021

Conversation

ChaseC99
Copy link
Member

@ChaseC99 ChaseC99 commented Feb 16, 2021

This PR implements the schedule query and establishes the CourseOffering type.

Test Plan

Verify that the following queries work as intended

{
  schedule(year: 2019, quarter: "Fall", department:"COMPSCI", course_number: "161") {
    title
    id
    offerings {
      year
      quarter
      instructors
      final_exam
      max_capacity
      meetings {
        time
        building
        days
      }
      num_section_enrolled
      num_total_enrolled
      num_on_waitlist
      num_requested
      num_new_only_reserved
      units
      restrictions
      status
      course {
        title
        id
      }
    }
  }
}
{
  course(id: "I&CSCI32A") {
    title
    offerings(year: 2019, quarter: "Fall") {
      year,
      quarter,
      final_exam,
      instructors,
      max_capacity,
      meetings {
      	building,
        days,
        time
      },
      num_section_enrolled,
      num_total_enrolled,
      num_new_only_reserved,
      num_on_waitlist,
      num_requested,
      restrictions,
      section {
        code, comment, number, type
      }
      status,
      units,
      course {
        id
        department_name
      }
    }
  }
}

Verify that the following queries throw an error. We do not support offerings on large nested lists from allCourses or an instructor's history

{
  professor(ucinetid:"pattis") {
    course_history {
    	offerings {
        final_exam
      }
    }
  }
  allCourses {
    offerings {
      status
    }
  }
}

This is just the intial commit.

Adds the schedule query and updates the course offering type.
Also creates a new helper file to query websoc.

There are still additional changes needed, such as error handling, input validation, and nested query optimizations.
Copy link
Member Author

@ChaseC99 ChaseC99 left a comment

Choose a reason for hiding this comment

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

So this is a start for the schedule query. There is still a decent amount that needs to be done before it is merged. I've noted some of my TODO items on the PR.

A few other things I wanted to mention:

  • We should consider downloading old websoc data and putting it in a sqlite db.
    Since the data from previous terms are static and won't change, there is no need for us to query websoc every time. We should store that locally. Having it in a local db would also allow us to do more complex lookups, such as showing every course a professor has taught (currently queries are restricted to just one year/quarter). Idk if clients would want that info but maybe it would be worth the effort ¯\(ツ)

  • This scheme file is getting BIG!
    After this PR, I think it's time to split the schemas up into separate files.

Comment on lines +120 to +122
// TODO: only return one error for a query, instead of one per item in the list
throw new Error(`Accessing a course's offerings from a nested list is not allowed. Please use the schedules query`)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Right now it will throw an error for each item in a nested list. So a client could end up with several dozen of the same errors lol. It's good that we have this in place because we don't want to send websoc several dozen requests. But I think we could clean up how we're presenting the error to the client.

TODO: only send one error back to the client.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly, just gonna leave this for now. Haven't been able to find a way to do this.

Comment on lines 163 to 167
num_section_enrolled: { type: GraphQLFloat },
num_total_enrolled: { type: GraphQLFloat },
num_new_only_reserved: { type: GraphQLFloat },
num_on_waitlist: { type: GraphQLFloat },
num_requested: { type: GraphQLFloat },
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if I'm happy with these field names. They seem really long...

TODO: find better names

Copy link
Member Author

Choose a reason for hiding this comment

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

@devsdevsdevs @Maybe14:
Can y'all take a look at the courseOfferingType fields and see if the names make sense to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is the difference between section_enrolled and total_enrolled? I'm assuming section_enrolled is for the, well, section LOL, like a lab. And total_enrolled is the total amount enrolled in the course (Like ICS 31 taught by Professor Kay).

graphql/schema.js Outdated Show resolved Hide resolved
graphql/schema.js Outdated Show resolved Hide resolved
helpers/schedule.helper.js Outdated Show resolved Hide resolved
graphql/schema.js Show resolved Hide resolved
@ChaseC99 ChaseC99 linked an issue Feb 16, 2021 that may be closed by this pull request
Must provide year and quarter
Must provide ge, department, section codes, or instructor
@ChaseC99 ChaseC99 marked this pull request as draft March 6, 2021 00:57
@ChaseC99 ChaseC99 changed the title [WIP] Add schedule query to Graphql Add schedule query to Graphql Mar 6, 2021
@ChaseC99 ChaseC99 linked an issue Mar 6, 2021 that may be closed by this pull request
If it is n/a, we return null.
I thought about returning 0, but there is actually an important distinction between the waitlist being open and no waitlist at all.
@ChaseC99 ChaseC99 requested review from tisuela and ramanxg March 8, 2021 04:05
@ChaseC99 ChaseC99 marked this pull request as ready for review March 8, 2021 04:06
@ramanxg
Copy link
Member

ramanxg commented Mar 10, 2021

For CourseOffering type for a schedule and course query, is the output supposed to behave differently for the different queries. I noticed that for the schedules, the arguments for the offering field is ignored.

This was the query I was testing it on:

# Write your query or mutation here
{
  schedule(year:2021, quarter:"Spring", department:"COMPSCI", course_number:"161") {
    id
    offerings(year:2020) {
      year
      quarter
      instructors
      final_exam
      num_total_enrolled
      max_capacity
    }
  }
}

Just wondering if this is the intended behavior. It's definitely better to not have a user write the same query over again, so I do agree, but it was unclear to me that this was the case. It could be mentioned in the documentation for graphql playground or on the generated graphql docs.

Also, I was looking over the schema.js file and 100% agree the file is way too large and hard to read, and would be very helpful if separated.

@ChaseC99
Copy link
Member Author

Just wondering if this is the intended behavior. It's definitely better to not have a user write the same query over again, so I do agree, but it was unclear to me that this was the case. It could be mentioned in the documentation for graphql playground or on the generated graphql docs.

The arguments are completely ignored for offerings under the schedule queries. I agree that's confusing... This happens because both queries share the same Course type. I'll look into potential solutions, maybe we could do something with parent/child classes (?)

Course's id, Instructor's ucinetid, and Schedule's year/quarter args are now required.
@tisuela
Copy link
Contributor

tisuela commented Mar 11, 2021

Just wondering if this is the intended behavior. It's definitely better to not have a user write the same query over again, so I do agree, but it was unclear to me that this was the case. It could be mentioned in the documentation for graphql playground or on the generated graphql docs.

The arguments are completely ignored for offerings under the schedule queries. I agree that's confusing... This happens because both queries share the same Course type. I'll look into potential solutions, maybe we could do something with parent/child classes (?)

Regarding including in Documentation, I can look into explicitly stating it on GraphQL playground. I think having more guidance on the playground (like a header made up of comments) was a feature previously requested. But other than that, the only other place we can state this behavior is on the MkDocs

Copy link
Contributor

@tisuela tisuela left a comment

Choose a reason for hiding this comment

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

naming looks good!

Comment on lines 163 to 167
num_section_enrolled: { type: GraphQLFloat },
num_total_enrolled: { type: GraphQLFloat },
num_new_only_reserved: { type: GraphQLFloat },
num_on_waitlist: { type: GraphQLFloat },
num_requested: { type: GraphQLFloat },
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is the difference between section_enrolled and total_enrolled? I'm assuming section_enrolled is for the, well, section LOL, like a lab. And total_enrolled is the total amount enrolled in the course (Like ICS 31 taught by Professor Kay).

@tisuela tisuela merged commit b91ab66 into master Apr 11, 2021
@ChaseC99 ChaseC99 deleted the graphql-schedule branch April 30, 2021 00:51
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

Successfully merging this pull request may close these issues.

GraphQL: Implement schedule query Course Offering Schema
3 participants