Fixes in subscriptions. It now passes the tests.
API tests still don't work.
This commit is contained in:
parent
e9165838dc
commit
47b8d80c22
16 changed files with 2649 additions and 975 deletions
|
@ -16,45 +16,15 @@ async function listDTAjax(context, params) {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
module.exports.get = (start, limit, search, callback) => {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
search = '%' + search + '%';
|
||||
connection.query('SELECT SQL_CALC_FOUND_ROWS `email` FROM blacklist WHERE `email` LIKE ? ORDER BY `email` LIMIT ? OFFSET ?', [search, limit, start], (err, rows) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
connection.query('SELECT FOUND_ROWS() AS total', (err, total) => {
|
||||
connection.release();
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
let emails = [];
|
||||
rows.forEach(email => {
|
||||
emails.push(email.email);
|
||||
});
|
||||
return callback(null, emails, total && total[0] && total[0].total);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
*/
|
||||
|
||||
async function search(context, start, limit, search) {
|
||||
async function search(context, offset, limit, search) {
|
||||
return await knex.transaction(async tx => {
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
|
||||
search = '%' + search + '%';
|
||||
|
||||
const count = await tx('blacklist').where('email', 'like', search).count();
|
||||
// FIXME - the count won't likely work;
|
||||
console.log(count);
|
||||
const count = await tx('blacklist').where('email', 'like', search).count('* as count').first().count;
|
||||
|
||||
const rows = await tx('blacklist').where('email', 'like', search).offset(start).limit(limit);
|
||||
const rows = await tx('blacklist').where('email', 'like', search).offset(offset).limit(limit);
|
||||
|
||||
return {
|
||||
emails: rows.map(row => row.email),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue