Skip to content

Commit

Permalink
2nd commit
Browse files Browse the repository at this point in the history
  • Loading branch information
haritha-j committed Mar 20, 2018
1 parent 1d47a96 commit 8b88643
Show file tree
Hide file tree
Showing 1,342 changed files with 95,021 additions and 103 deletions.
43 changes: 23 additions & 20 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var async = require('async');
const sqlite3 = require('sqlite3').verbose();


Expand Down Expand Up @@ -653,7 +654,7 @@ app.get('/prodxprod', function(req, res, next){
});
var amount = 0;

db.serialize(() =>{


db.all(`SELECT id id FROM product`, [], (err, rows) =>{
if(err) {
Expand All @@ -671,40 +672,48 @@ db.serialize(() =>{
var id2 = row.id;
var count =0;

db.all(`SELECT bill bill_id, FROM item where product_id=?`, [id1], (err, rows) =>{
var asyncOps = [

function (done) {
db.all(`SELECT bill_id bill_id FROM item where product_id=?`, [id1], (err, rows) =>{
if(err) {
console.error(err.message);
}
else{
rows.forEach((row) => {
var bill=row.bill;
db.all(`SELECT prod2 product_id, FROM item where bill=? and product_id=?`, [bill, prod2], (err, rows) =>{
var bill=row.bill_id;
db.all(`SELECT product_id product_id FROM item where bill_id=? and product_id=?`, [bill, id2], (err, rows) =>{
if(err) {
console.error(err.message);
}
else{
rows.forEach((row) => {
count+=1;
console.log(count);

});
}
});




});
}
});


//create a new entry in the product x product data table
db.run(`INSERT INTO prod_x_prod_data(product_id, rel_product_id, connections) VALUES(?, ?, ?)`, [id1, row.id2, count], function(err) {
},
//count finishes at this point
//create a new entry in the product x product data table
function(count) {
console.log(id2, count, id1);
db.run(`INSERT INTO prod_x_prod_data(product_id, rel_product_id, connections) VALUES(?, ?, ?)`, [id1, id2, count], function(err) {
if (err) {
return console.log(err.message);
}
console.log(`new connection created with id ${this.lastID}`);
});
}
];
async.waterfall(asyncOps, function (err, results){
if (err) return console.log(err);
});

});
}

Expand All @@ -713,16 +722,10 @@ db.serialize(() =>{
});
}
});
});
//end of serialized block.


db.close((err) => {
if (err) {
console.error(err.message);
}
console.log('Close the database connection.');
});



});

Expand Down
25 changes: 25 additions & 0 deletions node_modules/async-waterfall/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions node_modules/async-waterfall/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/async-waterfall/bower.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions node_modules/async-waterfall/component.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions node_modules/async-waterfall/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions node_modules/async-waterfall/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b88643

Please sign in to comment.