Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rbusquet/riobus-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor-costa committed Dec 4, 2014
2 parents 7f5ba65 + e4eac9e commit 6e7a6f3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
19 changes: 14 additions & 5 deletions dataQueuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ function callback(response) {

// Queue the requested data into queue.json
function appendDataAsync(data_to_append) {
fs.appendFile('queue.json', data_to_append, function (err) {
if (err) throw err;
});
//fs.appendFile('queue.json', data_to_append, function (err) {
//if (err) throw err;
//});
var date = new Date();
var file_name = moment(date).format("YYYYMMDDHH") + ".json";
fs.writeFile(__dirname + "/files/" + file_name, data_to_append, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
}

// Google's Big Query timestamp format, UTC time
Expand Down Expand Up @@ -68,7 +77,7 @@ setInterval(function() {

// Checks if data already has been generated by JSON.parse.
if(data != null) {
var formatted_data = data_formatter();
appendDataAsync(formatted_data);
// var formatted_data = data_formatter();
appendDataAsync(data);
}
}, intervalTime);
1 change: 1 addition & 0 deletions opa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opaopa
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "riobus-analytics",
"version": "0.1.1",
"description": "Riob.us analytics",
"main": "server.js",
"scripts": {
"start": "node riob-us/server.js"
},
"dependencies": {
"express": "~4.10.x"
},
"engines": {
"node": "0.10.x"
},
"keywords": [
"node",
"riobus"
],
"license": "GNU GPL2"
}
20 changes: 20 additions & 0 deletions report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var express = require('express')
var fs = require('fs')
var app = express()

app.get('/', function (req, res) {
var min_date = req.param('min_date'); // YYYMMDDHH
var max_date = req.param('max_date'); // YYYMMDDHH

var allfiles = fs.readdirSync(__dirname + "/files/").sort();
var files_to_use = [];
var l = allfiles.length;
var response = "";
for (var i = 0; i < l; i++) {
if (allfiles[i] >= min_date && allfiles[i] <= max_date) {
response += fs.readFileSync(__dirname + "/files/" + allfiles[i]) + "\n";
}
};


})

0 comments on commit 6e7a6f3

Please sign in to comment.