These are chat archives for ecjs/Concierge

20th
Nov 2014
Joe Elsey
@joeelsey
Nov 20 2014 02:21
heading home. I'll be back on online in about two hours from now.
Mark Harrell
@ecjs
Nov 20 2014 02:22
sounds good
Vincent
@vlee90
Nov 20 2014 02:35
Is there a route that can look up a user based on their jwt? I was thinking of saving the user's jwt into the applications UserDefaults. This would allow the jwt to persist on the local phone between sessions. Ideally, a check would be done on app launch for this jwt in UserDefaults. If it is there, the user skips the signup and login page completely and a call is done w/ the jwt to get the users information. If it isn't, then the user proceeds like normal.
Mark Harrell
@ecjs
Nov 20 2014 02:36
well it depends on what you want to lookup
so basically every single route, requires jwt (aside from forgot password routes)
basically, you just need to try and use the jwt..
if its expired..
then it will kick you out saying access denied..
and you will want to relogin
but when they first login, you will just want to check for maybe the concierge first
if they are a concierge, load the concierge screen with all of the concierge jobs
if they are not a concierge, load the user screen
with all of the user jobs
I can make a route for you that checks if the user is a concierge
right now we just have concierge registration and available/unavailable
Vincent
@vlee90
Nov 20 2014 02:40
Okay, for now, I'll try and work within those parameters and see if I can make it work out. I'll let you know if I need the new routes. Thanks for the quick reply!
Mark Harrell
@ecjs
Nov 20 2014 02:40
no problem
I will make that route right now
something we need anyways
check to see if user is concierge: true or fals
false
Chareesa Graham
@Chareesa
Nov 20 2014 02:45
Oh yea, we need something to turn the concierge back into a regular user.
Mark Harrell
@ecjs
Nov 20 2014 02:45
right, if they want to stop being a concierge
I can make t hat
Chareesa Graham
@Chareesa
Nov 20 2014 02:45
you sure? What should I be working on right now..
I can look into the concierge not answering
Mark Harrell
@ecjs
Nov 20 2014 02:46
you can make that one if you want
I am working on something else
Chareesa Graham
@Chareesa
Nov 20 2014 02:46
ok
Mark Harrell
@ecjs
Nov 20 2014 03:05
ok pushed some changes up to dev
Chareesa Graham
@Chareesa
Nov 20 2014 03:09
I just added the route to change back to a regular user to the register_concierge.. unless I should put it elsewhere?
Mark Harrell
@ecjs
Nov 20 2014 03:10
that works
Chareesa Graham
@Chareesa
Nov 20 2014 03:10
The code seems to work though. Just used what was up above.
Mark Harrell
@ecjs
Nov 20 2014 03:10
whats the route?
Chareesa Graham
@Chareesa
Nov 20 2014 03:11
coniergeToUser
Mark Harrell
@ecjs
Nov 20 2014 03:11
ok..
if it works go ahead and push up to dev and do a merge request
Chareesa Graham
@Chareesa
Nov 20 2014 03:22
sent
Mark Harrell
@ecjs
Nov 20 2014 03:22
merged
Chareesa Graham
@Chareesa
Nov 20 2014 03:23
route for change job..
hm
Mark Harrell
@ecjs
Nov 20 2014 03:23
oooo
u got dis ;P
var superagent = require('superagent');
var moment = require('moment');
var agent = superagent.agent();
var agent2 = superagent.agent();
var agent3 = superagent.agent();
var agent4 = superagent.agent();
var agent5 = superagent.agent();
var userPhone = '3607393580';
var conciergePhone = '5202227925';
var userJWT;
var conciergeJWT;
function makeUsers()  {
  agent
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: userPhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    userJWT = superRes.body.jwt;
    console.log(userJWT);
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(20, 'hours').utc().format(), recurring: true})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(1, 'minutes').utc().format(), recurring: false})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(28, 'hours').utc().format(), recurring: true})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
  });

  agent2
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test1@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: conciergePhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    conciergeJWT = superRes.body.jwt;
    console.log('concierge jwt: ' + conciergeJWT);
    agent3
    .post('https://salty-earth-1782.herokuapp.com/concierge')
    .send()
    .set('Content-Type', 'application/json')
    .set('jwt', conciergeJWT)
    .end(function(err2, superRes2) {
      if (err) return console.log('did not populate' + err + ' ' + superRes2);
    });
    agent4
    .post('https://salty-earth-1782.herokuapp.com/conciergeAvailable')
    .send()
    .set('Content-Type', 'application/json')
    .set('jwt', conciergeJWT)
    .end(function(err2, superRes2) {
      if (err) return console.log('did not populate' + err + ' ' + superRes2);
      conciergeJWT = superRes2.body.jwt;
    });
  });
}

makeUsers();
this is an updated script to run locally
remember to replace the phone numbers, as well as the heroku URL to the correct one
Chareesa Graham
@Chareesa
Nov 20 2014 03:29
how to you run it? I didn't figure it out. Not node..right? I never user superagent, so I dunno that one.
Mark Harrell
@ecjs
Nov 20 2014 03:29
yes
basically
node thisfile.js
Chareesa Graham
@Chareesa
Nov 20 2014 03:29
ok
Mark Harrell
@ecjs
Nov 20 2014 03:29
just make sure to change the info
before u do
Chareesa Graham
@Chareesa
Nov 20 2014 03:29
ok
Mark Harrell
@ecjs
Nov 20 2014 03:29
and that should work just fine
Mark Harrell
@ecjs
Nov 20 2014 03:34
just a little bug right now
pretty sure that the concierge is getting matched to a job
even if they are unavailable
Chareesa Graham
@Chareesa
Nov 20 2014 03:39
uhoh!
Mark Harrell
@ecjs
Nov 20 2014 03:39
yah..must be a database lookup issue
dang u MONGOOOOOOOSEEE
Mark Harrell
@ecjs
Nov 20 2014 03:53
made a slight alteration to the script that makes posts for jobs
var superagent = require('superagent');
var moment = require('moment');
var agent = superagent.agent();
var agent2 = superagent.agent();
var agent3 = superagent.agent();
var agent4 = superagent.agent();
var agent5 = superagent.agent();
var userPhone = '3607393580';
var conciergePhone = '5202227925';
var userJWT;
var conciergeJWT;
function makeUsers()  {
  agent
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: userPhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    userJWT = superRes.body.jwt;
    console.log(userJWT);
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(20, 'hours').utc().format(), recurring: true})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(1, 'minutes').utc().format(), recurring: false})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(28, 'hours').utc().format(), recurring: true})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
  });

  agent2
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test1@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: conciergePhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    conciergeJWT = superRes.body.jwt;
    console.log('concierge jwt: ' + conciergeJWT);
    agent3
    .post('https://salty-earth-1782.herokuapp.com/concierge')
    .send()
    .set('Content-Type', 'application/json')
    .set('jwt', conciergeJWT)
    .end(function(err2, superRes2) {
      if (err) return console.log('did not populate' + err + ' ' + superRes2);
      agent4
      .post('https://salty-earth-1782.herokuapp.com/conciergeAvailable')
      .send()
      .set('Content-Type', 'application/json')
      .set('jwt', conciergeJWT)
      .end(function(err2, superRes2) {
        if (err) return console.log('did not populate' + err + ' ' + superRes2);
        console.log('concierge is available?: ' + superRes2.body.conciergeAvailable);
      });
    });
  });
}

makeUsers();
nested the concierge true call
for better async
also, just made a push to dev
changed the timing for the queue add to 10 minutes from the call
and changed the send to twilio to within 3 minutes of the call
Joe Elsey
@joeelsey
Nov 20 2014 03:59
I'm back. You can all start coding now.
Chareesa Graham
@Chareesa
Nov 20 2014 04:00
I still can't get that to work :/
Always get this "did not populateError: socket hang up undefined"
Joe, how'd it go with Vincent?
He said you were helping
Mark Harrell
@ecjs
Nov 20 2014 04:06
you can test locally chareesa
you have to test it on your heroku app
Joe Elsey
@joeelsey
Nov 20 2014 04:06
Went well. He is in this chat room so you could ask as well... We just went over some of the basic endpoints that need to get covered.
Vincent
@vlee90
Nov 20 2014 04:07
For the
POST /confirm
route, what do I put as the BODY?
Joe Elsey
@joeelsey
Nov 20 2014 04:07
I'm 8 commits behind
Mark Harrell
@ecjs
Nov 20 2014 04:07
confirmationCode
(which is the users SMS)
Vincent
@vlee90
Nov 20 2014 04:09
Cool thanks!
What is the response (I'm not getting any confirmation texts on my phone) look like?
Mark Harrell
@ecjs
Nov 20 2014 04:10
we send back the entire user object
which contains confirmed: true or false
what we can do…is just return confirmed: true or false
Chareesa Graham
@Chareesa
Nov 20 2014 04:11
if you wanna know what the phone text says.. "Sent from your Twilio trial account - Here is your Concierge confirmation number 331761" -for example
Mark Harrell
@ecjs
Nov 20 2014 04:11
when we are using a non-trial account(for the demo) it wont say that
it will just say Here is your COncierge confirmation number
but you get the point
Vincent
@vlee90
Nov 20 2014 04:12
Ahh I see
Mark Harrell
@ecjs
Nov 20 2014 04:12
btw, I think I fixed the concierge matching
going to test it now
Vincent
@vlee90
Nov 20 2014 04:12
The entire user object should be fine I think...
Mark Harrell
@ecjs
Nov 20 2014 04:13
ok..
you will be able to parse it no matter what
going to test how I can break the system now
lol
no matching users..
concierge that is
what happens? ;)
Chareesa Graham
@Chareesa
Nov 20 2014 04:18
what!
are there users waiting to be matched?
and concierge isn't matching up?
Mark Harrell
@ecjs
Nov 20 2014 04:20
no..basically
I think I fixed the matching
but now I am doing an edge case
what happens if there is no user to match..
(what we want to happen, is that eventually we can get to a point where it tries again..
right now..if there is no concierge to match with the user..
its just going to bubble up errors
Vincent
@vlee90
Nov 20 2014 04:23

Sorry, another quick question.
POST
/resendConfirmation

What is put in the body? Thanks!

Chareesa Graham
@Chareesa
Nov 20 2014 04:23
that's the one I was looking at before leaving.. I didn't know..
thought it was username
Mark Harrell
@ecjs
Nov 20 2014 04:23
nothing
Chareesa Graham
@Chareesa
Nov 20 2014 04:23
ahh
Mark Harrell
@ecjs
Nov 20 2014 04:23
its a blank post
just resends a new confirmation code
simulating basically reregistering
creates a brand new sms code for them and tries to resend
just in case they didnt get the first one
Chareesa Graham
@Chareesa
Nov 20 2014 04:25
Oh @joeelsey did you see the new conciergeToUser route?
Joe Elsey
@joeelsey
Nov 20 2014 04:25
what can I help with?
no I haven't.
should I fetch the most recent upstream?
Chareesa Graham
@Chareesa
Nov 20 2014 04:25
It was a gift I made you
Mark Harrell
@ecjs
Nov 20 2014 04:25
yes def
There is definitely more tests that can be written at this point
routes have been added/changed
(i modified one of your tests to account for a changed route)
Vincent
@vlee90
Nov 20 2014 04:26
Cool, thanks!
Joe Elsey
@joeelsey
Nov 20 2014 04:26
ok. upstream fetched. lets see what tests break.
Mark Harrell
@ecjs
Nov 20 2014 04:27
nothing should break at this point
Joe Elsey
@joeelsey
Nov 20 2014 04:27
rue
true
Mark Harrell
@ecjs
Nov 20 2014 04:27
remember I have been pushing to dev :)
Joe Elsey
@joeelsey
Nov 20 2014 04:27
nothing broke.
Mark Harrell
@ecjs
Nov 20 2014 04:28
btw joe, merge with upstream/fix conflicts and then push back up and submit pull request
Joe Elsey
@joeelsey
Nov 20 2014 04:28
concierge jobs looks new
Mark Harrell
@ecjs
Nov 20 2014 04:28
I want that test 16 ;)
Joe Elsey
@joeelsey
Nov 20 2014 04:28
ok
before I start coding any new tests let me send a new pull request
everything passed
currently
Mark Harrell
@ecjs
Nov 20 2014 04:28
sounds good
I am going to start working on the fallback
for no matched concierge
so here is the deal..
we are going to be looking for a concierge within 10 minutes
we will check like one more time at 5 minutes
and if we still dont have one
we are going to revert to robo
sound good?
Joe Elsey
@joeelsey
Nov 20 2014 04:32
yes
Mark Harrell
@ecjs
Nov 20 2014 04:32
its going to be a tough one :P
Joe Elsey
@joeelsey
Nov 20 2014 04:33
I'm ready for a long day tomorrow.
Mark Harrell
@ecjs
Nov 20 2014 04:33
yah lets hit it hard
make sure that app is ticking like a clock
or a cron job :P
Joe Elsey
@joeelsey
Nov 20 2014 04:34
I want to write a test for the concierge job route that's been added.
@Chareesa is that the to user route?
Mark Harrell
@ecjs
Nov 20 2014 04:35
merged joes
chareesa make sure to sync up again
Chareesa Graham
@Chareesa
Nov 20 2014 04:35
one sec
register_concierge
wait
the route I made was in register_concierge to turn concierge to user
Joe Elsey
@joeelsey
Nov 20 2014 04:36
sweet
Mark Harrell
@ecjs
Nov 20 2014 04:41
ok..I have it so that its not producing a ton of errors
if there is no available concierge
Joe Elsey
@joeelsey
Nov 20 2014 04:41
concierge list?
Mark Harrell
@ecjs
Nov 20 2014 04:42
that produces a list of concierge jobs
rather..that produces a list of jobs that a concierge has queued up
Joe Elsey
@joeelsey
Nov 20 2014 04:49
So I wrote a test for the list of concierge jobs. I'm having it test for message right now because there are no jobs. I think I need to have the test create a concierge job to see if I can get that positive message instead of the error
Chareesa Graham
@Chareesa
Nov 20 2014 04:50
anyone having trouble with line 32 in jobManager.js?
or was that talked about..
Mark Harrell
@ecjs
Nov 20 2014 04:50
whats the error
Joe Elsey
@joeelsey
Nov 20 2014 04:50
its not a real error
just the message that there are no jobs
Mark Harrell
@ecjs
Nov 20 2014 04:50
I was talking about chareesas line 32 error in jobManager
Joe Elsey
@joeelsey
Nov 20 2014 04:50
because I haven't created one in the test
ah
nm
Chareesa Graham
@Chareesa
Nov 20 2014 04:51
/Users/user/Documents/devAccelerator/Concierge/lib/jobManager.js:32
        pickedConcierge: newConcierge._id
                                     ^
TypeError: Cannot read property '_id' of null
When I'm trying to test changing job details
Mark Harrell
@ecjs
Nov 20 2014 04:51
not sure why you are getting that error
not getting that over here
Chareesa Graham
@Chareesa
Nov 20 2014 04:51
hm. k
Joe Elsey
@joeelsey
Nov 20 2014 05:06
How would I make docs in the concierge list be greater than 0? I'm creating jobs, but I'm not getting a status 200 from the concierge list
Mark Harrell
@ecjs
Nov 20 2014 05:16
well, Joe..the only real way would be to run the function checkJobs = function() {
var jobStream = Jobs.find().stream();
jobStream.on('data', function(job) {
addToQueue(job);
});
};
wait
scratch that
you would need to run addToQueue(job)
job being the job id
I think
wait
Joe Elsey
@joeelsey
Nov 20 2014 05:17
let me try that.
Mark Harrell
@ecjs
Nov 20 2014 05:17
job is the full job collection
not just the id
Joe Elsey
@joeelsey
Nov 20 2014 05:17
I know
Mark Harrell
@ecjs
Nov 20 2014 05:17
soo
I dont think you will be able to run it
Joe Elsey
@joeelsey
Nov 20 2014 05:18
hrmm
Let me see if I can figure it out
Make myself useful
Mark Harrell
@ecjs
Nov 20 2014 05:20
that function isnt exported
so I think we would have to add it to exports
Joe Elsey
@joeelsey
Nov 20 2014 05:20
I can run the function in the test though?
Mark Harrell
@ecjs
Nov 20 2014 05:20
(not sure if that would break its availability to the other function, I dont think it would)
you dont want to bring that entire function in
addtoqueue is hufge
huge*
you are better off exporting it..
and potentially bringing it in to the test.
Joe Elsey
@joeelsey
Nov 20 2014 05:22
Yeah I woudn't copy paste. I'd do an export
Mark Harrell
@ecjs
Nov 20 2014 05:29
alright guys
just pushed up an update..
Chareesa Graham
@Chareesa
Nov 20 2014 05:29
k
Mark Harrell
@ecjs
Nov 20 2014 05:29
we are no succesfully falling back
now*
if we cant find a user, within 2 minutes of their scheduled callback
we make the robo call
Joe Elsey
@joeelsey
Nov 20 2014 05:30
awesome
Mark Harrell
@ecjs
Nov 20 2014 05:30
just tested it
Chareesa Graham
@Chareesa
Nov 20 2014 05:30
sweeeeet
Mark Harrell
@ecjs
Nov 20 2014 05:30
worked great ;)
passed all travis tests
:P
thats what I call a success.
Joe Elsey
@joeelsey
Nov 20 2014 05:33
sweet
concierge to user works. I just need to make a test for it
no 200 status yet for concierge list
Even if I make a user, create a job, then create a concierge with a different user, make that concierge available, and then check for jobs
Mark Harrell
@ecjs
Nov 20 2014 05:48
the job has to be within the next 10 minutes
if it is, it should add it to the queue
and also add it to the concierges list
Joe Elsey
@joeelsey
Nov 20 2014 05:49
ok
that might help
I'm creating jobs with 1 day added.
Let me see what happens with 9 minutes
All other tests are working. Added the concierge to user test
Chareesa Graham
@Chareesa
Nov 20 2014 05:56
Hey @joeelsey ! Now that you have testing experience, you should try TDD on my soon to be pushed app.put('/userJobs/:id' route
I'm trying to change the job
so job was created, now the user wants to change something. Either date or recurring
Joe Elsey
@joeelsey
Nov 20 2014 06:01
Will do
Chareesa Graham
@Chareesa
Nov 20 2014 06:01
woot woot!
I think I'm gonna change my lightning talk to that..
or just... testing strategies
Joe Elsey
@joeelsey
Nov 20 2014 06:02
I really want to make the tests more advanced. At this point its not very challenging to make the tests pass on at least one parameter. Would be interesting to write a test that gives conditions for every possible error and 200 status in a route.
six commits behind dev. let me know when I can fetch
19 tests and counting.
Mark Harrell
@ecjs
Nov 20 2014 06:17
I would go ahead and fetch
I havent coded for a while
trying to figure out how to redial a user after a timeout
Joe Elsey
@joeelsey
Nov 20 2014 06:21
done
Mark Harrell
@ecjs
Nov 20 2014 06:21
make sure to do a merge
i mean pull request
(getting late..lol)
Joe Elsey
@joeelsey
Nov 20 2014 06:24
done
I was only a couple of commits ahead
Mark Harrell
@ecjs
Nov 20 2014 06:26
merged!
success! ;)
Joe Elsey
@joeelsey
Nov 20 2014 06:31
Ok
I'm calling it a night.
See everyone tomorrow morning
Mark Harrell
@ecjs
Nov 20 2014 06:32
adios!
Chareesa Graham
@Chareesa
Nov 20 2014 07:18
sent pull request
Mark Harrell
@ecjs
Nov 20 2014 07:18
ok
currently experimenting with whats called a status callback url
for twilio
after a call is finished..
you can have it send a request to a URL with more info
which might be how we redial
Chareesa Graham
@Chareesa
Nov 20 2014 16:52
@vlee90 new route in Trello PUT /userJobs/:id
@ecjs running early morning tests?
Mark Harrell
@ecjs
Nov 20 2014 17:06
heading in now...was up late testing some Twilio stuff
We can talk about it when I get there
Chareesa Graham
@Chareesa
Nov 20 2014 17:08
@vlee90 Do we have a place for the user to type a message to concierge? Like for a birthday reminder?
Mark Harrell
@ecjs
Nov 20 2014 17:09
...might be a good, simple thing to do.
Joe Elsey
@joeelsey
Nov 20 2014 17:11
I picked up donuts
And are we still doing the stocks notify?
Mark Harrell
@ecjs
Nov 20 2014 17:15
Let's look into it today, decide if we can get it done.