-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vuthy
committed
Jan 13, 2019
1 parent
67b6a2c
commit e4547f3
Showing
6 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ module.exports.set = function(router, pool) { | |
// This query should be faster than the next one | ||
// After next query is done, code will use row_number to calcuate the pagination system | ||
var paginateArray = [] | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true';", (err, result) => { | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false';", (err, result) => { | ||
var row_number = result.rows[0].count; | ||
console.log("Row number is " + row_number) | ||
// Generate array of object based on number of rows, limit and start | ||
|
@@ -63,7 +63,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN account AS sender on (transfer_logs.sender = sender.email) \ | ||
JOIN account AS recipient on (transfer_logs.recipient = recipient.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true AND canceled = 'false' \ | ||
ORDER BY date DESC, recipient_username DESC OFFSET $1 LIMIT $2;", | ||
values: [start, limit] | ||
} | ||
|
@@ -115,7 +115,7 @@ module.exports.set = function(router, pool) { | |
var recentTransfer = { | ||
text: " SELECT transfer_logs.*, account.username as sender_username FROM transfer_logs \ | ||
JOIN account ON (transfer_logs.sender = account.email) \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC LIMIT 4;" | ||
} | ||
|
||
|
@@ -133,7 +133,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN (SELECT email, username, CASE WHEN role != 'apartment' THEN null ELSE username END AS apartment FROM account) AS account \ | ||
ON (transfer_logs.sender = account.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' AND transfer_logs.canceled = 'false' \ | ||
GROUP BY account.apartment ORDER BY account.apartment;" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ module.exports.set = function(router, pool) { | |
// This query should be faster than the next one | ||
// After next query is done, code will use row_number to calcuate the pagination system | ||
var paginateArray = [] | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true';", (err, result) => { | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false';", (err, result) => { | ||
var row_number = result.rows[0].count; | ||
console.log("Row number is " + row_number) | ||
// Generate array of object based on number of rows, limit and start | ||
|
@@ -64,7 +64,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN account AS sender on (transfer_logs.sender = sender.email) \ | ||
JOIN account AS recipient on (transfer_logs.recipient = recipient.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC, recipient_username DESC OFFSET $1 LIMIT $2;", | ||
values: [start, limit] | ||
} | ||
|
@@ -116,7 +116,7 @@ module.exports.set = function(router, pool) { | |
var recentTransfer = { | ||
text: " SELECT transfer_logs.*, account.username as sender_username FROM transfer_logs \ | ||
JOIN account ON (transfer_logs.sender = account.email) \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC LIMIT 4;" | ||
} | ||
|
||
|
@@ -134,7 +134,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN (SELECT email, username, CASE WHEN role != 'apartment' THEN null ELSE username END AS apartment FROM account) AS account \ | ||
ON (transfer_logs.sender = account.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' AND transfer_logs.canceled = 'false' \ | ||
GROUP BY account.apartment ORDER BY account.apartment;" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ module.exports.set = function(router, pool) { | |
// This query should be faster than the next one | ||
// After next query is done, code will use row_number to calcuate the pagination system | ||
var paginateArray = [] | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true';", (err, result) => { | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false';", (err, result) => { | ||
var row_number = result.rows[0].count; | ||
console.log("Row number is " + row_number) | ||
// Generate array of object based on number of rows, limit and start | ||
|
@@ -64,7 +64,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN account AS sender on (transfer_logs.sender = sender.email) \ | ||
JOIN account AS recipient on (transfer_logs.recipient = recipient.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC, recipient_username DESC OFFSET $1 LIMIT $2;", | ||
values: [start, limit] | ||
} | ||
|
@@ -116,7 +116,7 @@ module.exports.set = function(router, pool) { | |
var recentTransfer = { | ||
text: " SELECT transfer_logs.*, account.username as sender_username FROM transfer_logs \ | ||
JOIN account ON (transfer_logs.sender = account.email) \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC LIMIT 4;" | ||
} | ||
|
||
|
@@ -134,7 +134,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN (SELECT email, username, CASE WHEN role != 'apartment' THEN null ELSE username END AS apartment FROM account) AS account \ | ||
ON (transfer_logs.sender = account.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' AND transfer_logs.canceled = 'false' \ | ||
GROUP BY account.apartment ORDER BY account.apartment;" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ module.exports.set = function(router, pool) { | |
// This query should be faster than the next one | ||
// After next query is done, code will use row_number to calcuate the pagination system | ||
var paginateArray = [] | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true';", (err, result) => { | ||
pool.query("SELECT count(id) from transfer_logs WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false';", (err, result) => { | ||
var row_number = result.rows[0].count; | ||
console.log("Row number is " + row_number) | ||
// Generate array of object based on number of rows, limit and start | ||
|
@@ -58,7 +58,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN account AS sender on (transfer_logs.sender = sender.email) \ | ||
JOIN account AS recipient on (transfer_logs.recipient = recipient.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC, recipient_username DESC OFFSET $1 LIMIT $2;", | ||
values: [start, limit] | ||
} | ||
|
@@ -110,7 +110,7 @@ module.exports.set = function(router, pool) { | |
var recentTransfer = { | ||
text: " SELECT transfer_logs.*, account.username as sender_username FROM transfer_logs \ | ||
JOIN account ON (transfer_logs.sender = account.email) \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' \ | ||
WHERE recipient = '[email protected]' AND finished = 'true' AND canceled = 'false' \ | ||
ORDER BY date DESC LIMIT 4;" | ||
} | ||
|
||
|
@@ -128,7 +128,7 @@ module.exports.set = function(router, pool) { | |
FROM transfer_logs \ | ||
JOIN (SELECT email, username, CASE WHEN role != 'apartment' THEN null ELSE username END AS apartment FROM account) AS account \ | ||
ON (transfer_logs.sender = account.email) \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' \ | ||
WHERE transfer_logs.recipient = '[email protected]' AND transfer_logs.finished = 'true' AND transfer_logs.canceled = 'false' \ | ||
GROUP BY account.apartment ORDER BY account.apartment;" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters