-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Migrate tag api to new media model #312
Conversation
export const createInstance = (): MutableClimbDataSource => new MutableClimbDataSource(getClimbModel()) | ||
static instance: MutableClimbDataSource | ||
|
||
static getInstance (): MutableClimbDataSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a singleton factory
chore: move datasources to singleton factory pattern
updateUserProfile: and(isOwner, isValidEmail) | ||
updateUserProfile: and(isOwner, isValidEmail), | ||
addEntityTag: or(isMediaOwner, isUserAdmin), | ||
removeEntityTag: or(isMediaOwner, isUserAdmin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag mutations now require permission checks
import { MUUID } from 'uuid-mongodb' | ||
import { Point } from '@turf/helpers' | ||
|
||
export type ImageFormatType = 'jpeg' | 'png' | 'webp' | 'avif' | ||
|
||
export interface MediaObject { | ||
_id: ObjectId | ||
_id: mongoose.Types.ObjectId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've been using ObjectId type incorrectly.
mongoose.Types.ObjectId
is the typescript type and also the class to generate new mongo object idmongoose.ObjectId
should only be used for describing the schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviving media tag API
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing Visual Studio code debugging configs related to media migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like the use of the singleton pattern. Should reduce memory usage!
import { AreaType } from '../../db/AreaTypes.js' | ||
import { EntityTag, MediaObject, MediaObjectGQLInput, AddTagEntityInput } from '../../db/MediaObjectTypes.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been favoring writing integration tests so that we can validate and document the graphQL layer as well rather than just data sources down. They are in src/__tests__/
. We could add tests at both layers too, but I'd suggest writing the integration tests if we're only going to write one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We can also test the permission layer that way. I've been writing data source tests out of habit. I'll fix it in a future PR.
Issue #281
Clean up