Code Monkey home page Code Monkey logo

pear-backend-graphql's Introduction

GraphQL-MongoDB

All the important starting code is in src/start.js. Models and the schema representation is split up in files in src/models

We will be using yarn for this repo, not npm

To install the required managers, use brew:

On Linux: sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" (You may need to add brew to the path afterwards)

On MacOS: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install dependencies with:

brew install node yarn
yarn install

Yarn Build / Run:

yarn build
yarn start

Dev Hot-Reload:

yarn startdev

To run tests you must have the CircleCI CLI and Docker Installed To install CircleCI

brew install circleci

To install Docker it is recommended to go to their website and install Docker Desktop https://docs.docker.com/docker-for-mac/install/

We will also be using git flow to track release versioning To start on a new feature use

git flow feature start featurename

To merge that feature into develop: ** Do not run git flow feature finish featurename** First, publish the feature to github, using:

  • git flow feature publish featurename
  • Create a pull request on github into devlop
  • Get the pull request reviewed
  • Merge the pull request into develop
  • Delete the feature branch on remote and locally

Writeups on gitflow

https://nvie.com/posts/a-successful-git-branching-model/
https://jeffkreeftmeijer.com/git-flow/
https://github.com/nvie/gitflow

To set up linting scripts run from root project folder:

cp pre-commit .git/hooks

You shouldn't be able to push directly to master; instead, create and merge PRs.

To add npm packages also user yarn

yarn add package
yarn add --dev package

Upload schema to Apollo:

apollo service:push --key="service:pear-matchmaking-8936:V43kf4Urhi-63wQycK_yoA" --endpoint=host/graphql  --tags="Optional tags"

Deployment

We will be using pm2 for cluster deployment Our two servers are koala.mit.edu (prod) and sloths.mit.edu (dev)

To update a deploy, pull the latest changes, build them into dist with yarn build, then pm2 reload to perform a zero-downtime reload.

To install pm2:

npm install pm2 -g && pm2 update
pm2 completion install

To monitor the deployment: pm2 monit

To list instances: pm2 ls

To start a pm2 deploy pm2 start pm2.config.json --env development/production

Other helpful commands

pm2 delete all
pm2 logs all

pear-backend-graphql's People

Contributors

averylamp avatar gubsheep avatar joelaguero avatar

Stargazers

Jingwei Ma avatar Zachary Pitcher avatar Jordan Wick avatar Cat Zeng avatar  avatar

Watchers

James Cloos avatar  avatar

pear-backend-graphql's Issues

detachedProfileResolver doesn't handle errors properly

  1. getAndValidateUsersAndDetachedProfileObjects should return a Promise.reject, not throw. Throwing causes bad things to happen when we write something like let foo = await getAndValidateUsers...
  2. Profile creation: write a check to make sure the person doesn't already have an open UP/DP for the phone number they're making a new DP for.
  3. Profile approval: write a check to make sure the person hasn't already approved a profile written by creator.

In GetDiscoveryQueue Last Parameter Has no effect

Signature:
getDiscoveryFeed(user_id: ID!, last: Int): DiscoveryQueue
Does not actually user last in resolver:
getDiscoveryFeed: async (_, { user_id }) => {

Would be nice to user last because it would improve loading times

Bug: End of Discovery Profile Attaching Discovery Queue Generation

Bug at the end of discovery

// all operations succeeded; populate discovery feeds if this the endorsee's first profile
try {
const feed = await DiscoveryQueue.findById(user.discoveryQueue_id);
if (feed.currentDiscoveryItems.length === 0) {
  for (let i = 0; i < INITIALIZED_FEED_LENGTH; i += 1) {
    await updateDiscoveryWithNextItem(user);
  }
}
} catch (e) {
errorLog(`error occurred when trying to populate discovery feed: ${e}`);
debug(`error occurred when trying to populate discovery feed: ${e}`);
}

Duplicates appear after reopening the app

Although I "swiped" on people already, they all reappear and I am presented with them again. People shouldn't appear after they've been "swiped" on. @Averylamp mentioned this is a backend issue so just creating it here.

Possibly related/duplicate of #133

Prod Errors

  error:DiscoverProfile Error: no users found in constraints
  error:DiscoverProfile     at _callee$ (/home/avery/Private/backend-graphql/dist/discovery/DiscoverProfile.js:90:17)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at Generator.invoke [as _invoke] (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runt
ime.js:303:22)
  error:DiscoverProfile     at Generator.prototype.(anonymous function) [as next] (/home/avery/Private/backend-graphql/node_modules/reg
enerator-runtime/runtime.js:117:21)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at invoke (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:155:20)
  error:DiscoverProfile     at /home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:165:13
  error:DiscoverProfile     at processTicksAndRejections (internal/process/next_tick.js:81:5) +9m
  error:DiscoverProfile Couldn't find profile in constraints for endorsed profile: 5ca67b9230bf78cac2ed431f +1ms
  error:DiscoverProfile Error: no users found in constraints
  error:DiscoverProfile     at _callee$ (/home/avery/Private/backend-graphql/dist/discovery/DiscoverProfile.js:90:17)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at Generator.invoke [as _invoke] (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runt
ime.js:303:22)
  error:DiscoverProfile     at Generator.prototype.(anonymous function) [as next] (/home/avery/Private/backend-graphql/node_modules/reg
enerator-runtime/runtime.js:117:21)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at invoke (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:155:20)
  error:DiscoverProfile     at /home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:165:13
  error:DiscoverProfile     at processTicksAndRejections (internal/process/next_tick.js:81:5) +44ms
  error:DiscoverProfile Couldn't find profile in constraints for detached profile: 5ca683cf30bf78cac2ee43de +0ms
  error:DiscoverProfile Error: no users found in constraints
  error:DiscoverProfile     at _callee$ (/home/avery/Private/backend-graphql/dist/discovery/DiscoverProfile.js:90:17)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at Generator.invoke [as _invoke] (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runt
ime.js:303:22)
  error:DiscoverProfile     at Generator.prototype.(anonymous function) [as next] (/home/avery/Private/backend-graphql/node_modules/reg
enerator-runtime/runtime.js:117:21)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at invoke (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:155:20)
  error:DiscoverProfile     at /home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:165:13
  error:DiscoverProfile     at processTicksAndRejections (internal/process/next_tick.js:81:5) +38ms
  error:DiscoverProfile Couldn't find profile in constraints for detached profile: 5ca67b5430bf78cac2ed3f98 +1ms
  error:DiscoverProfile Error: no users found in constraints
  error:DiscoverProfile     at _callee$ (/home/avery/Private/backend-graphql/dist/discovery/DiscoverProfile.js:90:17)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at Generator.invoke [as _invoke] (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runt
ime.js:303:22)
  error:DiscoverProfile     at Generator.prototype.(anonymous function) [as next] (/home/avery/Private/backend-graphql/node_modules/reg
enerator-runtime/runtime.js:117:21)
  error:DiscoverProfile     at tryCatch (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:65:40)
  error:DiscoverProfile     at invoke (/home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:155:20)
  error:DiscoverProfile     at /home/avery/Private/backend-graphql/node_modules/regenerator-runtime/runtime.js:165:13
  error:DiscoverProfile     at processTicksAndRejections (internal/process/next_tick.js:81:5) +52ms
  error:DiscoverProfile Couldn't find profile in constraints for endorsed profile: 5ca681b030bf78cac2edcd31 +1ms
  error:DiscoverProfile No suggested discovery items for User: 5ca6140a30bf78cac2ed2d29 +0ms

mutations for skip, wave, and pear

skip mutation to be written
wave and pear mutations (createNewRequest) to also remove the profile from discovery queue
clean up the rollback logic

Add Referral tracking

Probably in user schema an optional field for where they were referred from.
Bonus points for on user schema creation, create a unique human readable id for each user to use as their own referral code. i.e. Uber does Avery###, for my referral code.

deploy discovery drip

this has four parts:
(1) clear out everyone's current discovery queue
(2) add 3 profiles to everyone's discovery queue to start
(3) start running discovery drip script
(4) swap the resolver so that we serve people their queue, not the most recent profiles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.