task

4800-v-004-002

[previously]

  1. [2015-06-09] NEW task IN PAGE rankings
    1. x]  # # - UPDATE rankings - use REQUEST to pull data from api - i] revisiting pulling the drivers data FROM src=sospep.people using api call, ]  see TRY 1, TRY 2, TRY 3 and TRY 4 ] SUCCESS with TRY 4 using the 'request' package, see example code in homes.js-v-001
  2. [2015-06-10] NEW task IN PAGE
    1. ] # # - CREATE-module - getEntrants - put code for pulling entrants data, then processing it, into a seperate module(VS in index 'controller)

[currently]

  1. [2015-06-10] NEW task IN
    1. ] # # - request api - lets get that request working properly,  http.get request
    2. *]  TRY 1 - SRC = SO ? http://stackoverflow.com/questions/9577611/http-get-request-in-node-js-express response # 2
    3. *] uses = http
    4. ] SUCCESS - try# 4 
  2. [00:00] NEW task IN
    1. ] # # - data  
    2. ] var url = 'http://sospep.com/qry/Select-IndividualsInMemberGroup-a/25';   //returns nascar drivers list
    3. ] { race: '2015-13', id: 107, nameDriver: 'Ricky Stenhouse Jr', teamID: '17', points: 0, top10s: 'one', description: 'ricky is awesome' },
  3. * [00:00] NEW task IN
    1. ] # # - use existing 'drivers' to create an 'entrants list'
    2. ] person - HAS id, name
    3. ] request json - all
    4. ] iterate 'records' and add desired properties to each driver record NEED ADD - ] race, ] teamID, ] points ] top10(CALC)
    5. ] PRB teamID - create/use lookupDriver function
    6. ] save as file
    7. ] pull data for view from file
    8. ] admin command to /get-entrants
  4. [00:00] NEW task IN sospep/membergroup/ {nations/nascar/drivers}
    1. x] # # -  data - drivers
    2. x] changed person.status of non active drivers(7) to 'asked' from default of ask, USE this param to pull just the drivers entered in a given race
  5. [00:00] NEW task IN sospep app
    1. x] # # - app sospep - make new dir x] api
  6. [00:00] NEW task IN sospep app pages
    1. x] # # - sospep - NEW endpoint - raceEntrants
    2. x] = ( copy SelectIndividualsInMemberGroup-a /{membergroup id} /{status}  
      1. ] COMPARE MemberGroup-a - concats first and last to return fullname
      2. ] VS MemberGroup - returns first and last name
      3. ]
    3. ] ?? == current session
    4. *] this gets me a 'pseudo list' of entrants for the current race *, still NEED the actual list of entrants ..
  7. > [00:00] NEW task IN
    1. ] # # - actual entrants - COMPARE
  8. > [00:00] NEW task IN PASS - rankings
    1. x] # # - get entrants (aka drivers) for current race - x] call new api,
  9. > [00:00] NEW task IN PASS - rankings
    1. ] # # - TRY CREATE module for 'getEntrants' code
    2. ] var entrants = [
    3. ];
    4. module.exports(getEntrants)
    5. ] iterate the list of drivers to ADD additional properties
  10. [00:00] NEW task IN
    1. ] # # -  CREATE module - take logic for building entrants list, move into module
    2. ] using module.exports = function(){} then ADD route VS
    3. ] using var myModule = { properties:'values'} module.exports(myModule) then ADD route
  11. [00:00] NEW task IN NOTE
    1. ] entrants.js - v-001 = first example, see 10.3, 500 error
    2. ] entrants.js -v-002 = simple example of passing data
    3. *] PAGE (ex index) requires var entrants = requries entrants.js, CANT invoke
  12. [00:00] NEW task IN NOTE its WORKING (it may NOT be right, but it is working)
    1. ] filename.js - using module.exports, ex entrants.js
    2. ] include pseudo path to .js file in app.js routes section, example = require('./routes/entrants')(app);
    3. ] define var in file using - ex index - var drivers = require('./filename')
    4. ] call var function where you need entrants()
    5. CC] # # - understanding expressjs - ]
  13. [2015-06-11] DONE
    1. ] teams table, manually loaded data
    2. ] lookup function, lookup teamID by driverID, 
      1. ] fails on loop,
      2. ] seems to work on invidual
    3. ] sospep data - add prop 'priority' to race entrants, USE for teamID
    4. ] adjust getEntrants api endpoint to return property
  14. ] DO
    1. ] driver (description w/{}, )
    2. ] rankRace15
    3. ]- avgfinish-last10 races
    4. >] ]
  15. ]

[next]

  1. ]

 


TRY 1 
	var http = require('http');
        var options = {
            host: 'sospep.com',
            path: '/qry/Select-IndividualsInMemberGroup-a/25'
        };
 
        var reqDrivers = http.get(url, function (res1) {
            console.log('STATUS: ' + res1.statusCode);
            console.log('HEADERS: ' + JSON.stringify(res1.headers));
 
            // Buffer the body entirely for processing as a whole.
            var bodyChunks = [];
            res1.on('data', function (chunk) {
                // You can process streamed parts here...
                bodyChunks.push(chunk);
            }).on('end', function () {
                var body = Buffer.concat(bodyChunks);
                // console.log('BODY: ' + body);
                // ...and/or process the entire body here.
                // body = JSON.parse(body);
            })
        });
 
        reqDrivers.on('error', function (e) {
            console.log('ERROR: ' + e.message);
        });

 


 TRY 2 https://docs.nodejitsu.com/articles/HTTP/clients/how-to-create-a-HTTP-request

var scoot = '';
 
        var http = require('http');
 
        callback = function (response) {
 
            var str = '';
            //another chunk of data has been recieved, so append it to `str`
            response.on('data', function (chunk) {
                str += chunk;
            });
            //the whole response has been recieved, so we just print it out here
            response.on('end', function () {
                console.log(str);
                // return JSON.stringify(str);
                           });
        }
        http.request(url, callback).end();
 
        // var str = '';

 TRY 3 - use previous example code in home.js page,

successfully pulled data from api and piped that data to a file on the server

using request package, try get vs fs

TRY 4 - use tutorial in art# 4566

KEY - moving the http request outside of the app.get(){ } function

 

 

 

 

Details Photos Edit more

Details

ID: 5273

NAME: 4800-v-004-002

DESCRIPTION: #### - UPDATE - PAGE rankings - use REQUEST to pull data from external rankings api, TRY rankings module

START DATE TIME: 2015-06-10 13:27:26

EST DURATION: 01:00:00

END DATE TIME: 2015-06-10 14:27:26

STATUS: Completed

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

photos for this task

actions

Agenda Email task SMS task Priorities