Cosmetic changes
This commit is contained in:
parent
97d5d1a462
commit
8caf334fcc
2 changed files with 28 additions and 30 deletions
|
@ -13,6 +13,7 @@ let log = require('npmlog');
|
||||||
let mailer = require('../mailer');
|
let mailer = require('../mailer');
|
||||||
let humanize = require('humanize');
|
let humanize = require('humanize');
|
||||||
let _ = require('../translate')._;
|
let _ = require('../translate')._;
|
||||||
|
let util = require('util');
|
||||||
|
|
||||||
let allowedKeys = ['description', 'from', 'address', 'reply_to', 'subject', 'editor_name', 'editor_data', 'template', 'source_url', 'list', 'segment', 'html', 'text', 'tracking_disabled'];
|
let allowedKeys = ['description', 'from', 'address', 'reply_to', 'subject', 'editor_name', 'editor_data', 'template', 'source_url', 'list', 'segment', 'html', 'text', 'tracking_disabled'];
|
||||||
|
|
||||||
|
@ -201,33 +202,33 @@ module.exports.statsClickedSubscribersByColumn = (campaign, linkId, request, col
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let values = [campaign.list, linkId];
|
let query_template = 'SELECT %s AS data, COUNT(*) AS cnt FROM `subscription__%d` JOIN `campaign_tracker__%d` ON `campaign_tracker__%d`.`list`=%d AND `campaign_tracker__%d`.`subscriber`=`subscription__%d`.`id` AND `campaign_tracker__%d`.`link`=%d GROUP BY `%s` ORDER BY COUNT(`%s`) DESC, `%s`';
|
||||||
let query = 'SELECT SQL_CALC_FOUND_ROWS ' + column + ' AS data, COUNT(*) AS cnt FROM `subscription__' + campaign.list + '` JOIN `campaign_tracker__' + campaign.id + '` ON `campaign_tracker__' + campaign.id + '`.`list`=? AND `campaign_tracker__' + campaign.id + '`.`subscriber`=`subscription__' + campaign.list + '`.`id` AND `campaign_tracker__' + campaign.id + '`.`link`=? GROUP BY ' + column + ' ORDER BY COUNT(' + column + ') DESC,' + column;
|
let query = util.format(query_template, column, campaign.list, campaign.id, campaign.id, campaign.list, campaign.id, campaign.list, campaign.id, linkId, column, column, column);
|
||||||
|
|
||||||
connection.query(query, values, (err, rows) => {
|
connection.query(query, (err, rows) => {
|
||||||
connection.release();
|
connection.release();
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
|
||||||
|
|
||||||
let data = {};
|
|
||||||
let dataPercent = [];
|
|
||||||
let total = 0;
|
|
||||||
|
|
||||||
rows.forEach(function (row, index) {
|
|
||||||
if (index < limit) {
|
|
||||||
data[row.data] = row.cnt;
|
|
||||||
} else {
|
|
||||||
data.other = (data.other ? data.other : 0) + row.cnt;
|
|
||||||
}
|
}
|
||||||
total += row.cnt;
|
|
||||||
});
|
let data = {};
|
||||||
Object.keys(data).forEach(function (key) {
|
let dataPercent = [];
|
||||||
let name = key + ': ' + data[key];
|
let total = 0;
|
||||||
let value = parseInt(data[key] * 100 / total);
|
|
||||||
dataPercent.push([name, value]);
|
rows.forEach((row, index) => {
|
||||||
});
|
if (index < limit) {
|
||||||
return callback(null, dataPercent, total);
|
data[row.data] = row.cnt;
|
||||||
|
} else {
|
||||||
|
data.other = (data.other ? data.other : 0) + row.cnt;
|
||||||
|
}
|
||||||
|
total += row.cnt;
|
||||||
|
});
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
let name = key + ': ' + data[key];
|
||||||
|
let value = parseInt(data[key] * 100 / total, 10);
|
||||||
|
dataPercent.push([name, value]);
|
||||||
|
});
|
||||||
|
return callback(null, dataPercent, total);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,7 @@ SET @schema_version = '22';
|
||||||
|
|
||||||
# Create ALTER TABLE PROCEDURE
|
# Create ALTER TABLE PROCEDURE
|
||||||
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
||||||
DELIMITER //
|
CREATE PROCEDURE `alterbyregexp` (`table_regexp` VARCHAR(255), `altertext` VARCHAR(255))
|
||||||
CREATE PROCEDURE alterbyregexp(`table_regexp` VARCHAR(255), `altertext` VARCHAR(255))
|
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE done INT DEFAULT FALSE;
|
DECLARE done INT DEFAULT FALSE;
|
||||||
DECLARE tbl VARCHAR(255);
|
DECLARE tbl VARCHAR(255);
|
||||||
|
@ -27,8 +26,6 @@ DEALLOCATE PREPARE stmt;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE curs;
|
CLOSE curs;
|
||||||
END;
|
END;
|
||||||
//
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
||||||
# Add field device_type to campaign_tracker
|
# Add field device_type to campaign_tracker
|
||||||
CALL alterbyregexp('campaign\_tracker%', 'ADD COLUMN `device_type` varchar(50) DEFAULT NULL AFTER `ip`');
|
CALL alterbyregexp('campaign\_tracker%', 'ADD COLUMN `device_type` varchar(50) DEFAULT NULL AFTER `ip`');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue