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

Improved Error Handling for Queries, Simplified Logic, and Formatted README #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 107 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,135 @@

[![codecov](https://codecov.io/gh/Michigan-Tech-Courses/rate-my-professors/branch/master/graph/badge.svg?token=YSBV5T5GVY)](https://codecov.io/gh/Michigan-Tech-Courses/rate-my-professors)

A basic wrapper for Rate My Professors's GraphQL API. Includes TypeScript definitions.
A basic wrapper for Rate My Professors' GraphQL API, including TypeScript definitions. This package retrieves school and professor information with capabilities to retrieve detailed ratings of professors.

It is possible to pull full ratings with content as well, but currently this package just returns the average.
## 🚀 Getting Started

## 🏗 Usage
### Installation

```js
// Change to
// const ratings = require('@mtucourses/rate-my-professors').default;
// if using JS instead of TS
import ratings from '@mtucourses/rate-my-professors';
To install the package, run:

(async () => {
const schools = await ratings.searchSchool('michigan technological university');
```bash
npm install @mtucourses/rate-my-professors
or
pnpm install @mtucourses/rate-my-professors
```

console.log(schools);
/*
[
{
city: 'Houghton',
id: 'U2Nob29sLTYwMg==',
name: 'Michigan Technological University',
state: 'MI'
}
]
*/
# Usage

const teachers = await ratings.searchTeacher('mtu shene');
```ts
// Use the following line if using JavaScript instead of TypeScript
// const ratings = require('@mtucourses/rate-my-professors').default;
import ratings from "@mtucourses/rate-my-professors";

console.log(teachers);
(async () => {
// Search for a school
const schools = await ratings.searchSchool("arizona state university");
/*
[
{
firstName: 'Ching-Kuang',
id: 'VGVhY2hlci0yMjkxNjI=',
lastName: 'Shene',
school: {
id: 'U2Nob29sLTYwMg==',
name: 'Michigan Technological University'
}
}
]
[
...response truncated for brevity
{
city: '',
id: 'U2Nob29sLTEzNjQ3',
name: 'Arizona State University',
state: ''
},
{
city: 'Tucson',
id: 'U2Nob29sLTE1NzIz',
name: 'Arizona State University',
state: 'AZ'
},
...response truncated for brevity
]
*/

const teacher = await ratings.getTeacher('VGVhY2hlci0yMjkxNjI=');

console.log(teacher);
// Search for a teacher at a specific school
const teachers = await ratings.searchTeacher(
"steven osburn",
"U2Nob29sLTEzNjQ3"
);
/*
[
{
avgDifficulty: 4.4,
avgRating: 3.3,
numRatings: 28,
department: 'Computer Science',
firstName: 'Ching-Kuang',
id: 'VGVhY2hlci0yMjkxNjI=',
lastName: 'Shene',
school: {
city: 'Houghton',
id: 'U2Nob29sLTYwMg==',
name: 'Michigan Technological University',
state: 'MI'
},
legacyId: 1234567
firstName: 'Steven',
id: 'VGVhY2hlci0yMzAwOTAw',
lastName: 'Osburn',
school: { id: 'U2Nob29sLTEzNjQ3', name: 'Arizona State University' }
}
]
*/

// Get detailed information about a teacher
const teacher = await ratings.getTeacher("VGVhY2hlci0yMzAwOTAw");
/*
{
avgDifficulty: 2.5,
avgRating: 4.3,
department: 'Engineering',
firstName: 'Steven',
id: 'VGVhY2hlci0yMzAwOTAw',
lastName: 'Osburn',
legacyId: 2300900,
numRatings: 79,
school: {
city: '',
id: 'U2Nob29sLTEzNjQ3',
name: 'Arizona State University',
state: ''
},
wouldTakeAgainPercent: 88.8889
}
*/
Copy link
Member

Choose a reason for hiding this comment

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

I think these commented out responses are still useful to show the basic shape of the available data (open to editing it to make it a more generalized example though)

Copy link
Author

Choose a reason for hiding this comment

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

Got it, we can add them back.

})();
```

## 🧰 Development
# API

### `searchSchool(searchQuery: string): Promise<School[]>`

Searches for a school by its name.

### `searchTeacher(searchQuery: string): Promise<Teacher[]>`

Searches for a teacher by their name or school abbreviation.

### `getTeacher(teacherId: string): Promise<TeacherDetails>`

Retrieves detailed information about a teacher by their ID.

# Development

## Setup

```bash
# First:
# install dependencies
yarn install
# Install dependencies
npm install
```

# then:
# build in watch mode
yarn build:watch
## Build

# and you can:
```bash
# Build in watch mode
npm run build:watch
```

## Testing

# run tests
yarn test
```bash
# Run tests
npm test

# run tests in watch mode
yarn test:watch
Comment on lines 106 to -90
Copy link
Member

Choose a reason for hiding this comment

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

very minor but I like the old format here haha

Copy link
Author

Choose a reason for hiding this comment

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

Didn't you mention that yarn is not recommended, so I just used npm for all of them.

Copy link
Member

Choose a reason for hiding this comment

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

yeah I'm fine switching to npm, just liked the old wording a bit more

# Run tests in watch mode
npm run test:watch
```

To publish a new package version, run `npm version [patch|minor|major]` and then `git push && git push --tags` on the master branch.
# Contributors

[codetheweb](https://github.com/codetheweb)

[Leo6Leo](https://github.com/Leo6Leo)

[patrickdemers6](https://github.com/patrickdemers6)

[spabolu](https://github.com/spabolu)
Loading