-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
140 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { RatingType } from '@repo/common'; | ||
|
||
export async function getRatingsByClass(): Promise<null> { | ||
return null; | ||
} | ||
|
||
export async function createRating(rating: RatingType): Promise<null> { | ||
rating; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import resolver from "./resolver"; | ||
import typeDef from "./typedefs/rating"; | ||
|
||
export default { | ||
resolver, | ||
typeDef, | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { gql } from "graphql-tag"; | ||
|
||
const typedef = gql` | ||
type HistogramEntry { | ||
value: Int! | ||
count: Int! | ||
class: String! | ||
} | ||
type ClassHistogram { | ||
class: Class | ||
histogram: [HistogramEntry!] | ||
} | ||
type RatingSummary { | ||
name: String! | ||
class_histogram: [ClassHistogram!] | ||
overall_histogram: [HistogramEntry!] | ||
totalCount: Int! | ||
average: Float! | ||
} | ||
type Rating { | ||
class: Class! | ||
name: String! | ||
value: Int! | ||
} | ||
type Query { | ||
rating(name: String!, subject: String!, number: String!): RatingSummary! | ||
user_ratings(subject: String!, number: String!): [Rating] @auth | ||
} | ||
type CreateRatingInput { | ||
class: String! | ||
name: String! | ||
value: Int! | ||
} | ||
type Mutation { | ||
createRating(rating: CreateRatingInput): @auth | ||
deleteRating(): @auth | ||
} | ||
`; | ||
|
||
export default typedef; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import mongoose, { InferSchemaType, Schema } from "mongoose"; | ||
|
||
const ratingSchema = new Schema({ | ||
_id: Schema.Types.ObjectId, | ||
google_id: { | ||
type: String, | ||
trim: true, | ||
required: true, | ||
immutable: true, | ||
select: false, | ||
}, | ||
email: { | ||
type: String, | ||
trim: true, | ||
required: true, | ||
immutable: true, | ||
}, | ||
class: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Class', | ||
required: true, | ||
immutable: true | ||
}, | ||
// likert int 1 -> 5 values | ||
// boolean 0/1 values | ||
// string properties assign hash code | ||
value: { | ||
type: Number, | ||
required: true, | ||
validate: { | ||
validator: Number.isInteger, | ||
} | ||
}, | ||
// indicate value type (granularity: specific questions) | ||
value_type: { | ||
type: String, | ||
required: true, | ||
} | ||
}, { | ||
timestamps: { | ||
createdAt: "createdAt", | ||
updatedAt: "updatedAt", | ||
}, | ||
}); | ||
|
||
export const RatingModel = mongoose.model( | ||
"crowdsource_rating", | ||
ratingSchema, | ||
"crowdsource_rating" | ||
); | ||
|
||
export type RatingType = InferSchemaType<typeof ratingSchema>; |