* Moved all direct SQL statements as constants into Sql object
* Removed redundant call for HopObject.log() in Admin.update() method
This commit is contained in:
parent
499e8d97b9
commit
33ef009f20
5 changed files with 30 additions and 22 deletions
|
@ -175,8 +175,7 @@ Admin.purgeSites = function() {
|
||||||
*/
|
*/
|
||||||
Admin.purgeReferrers = function() {
|
Admin.purgeReferrers = function() {
|
||||||
var sql = new Sql;
|
var sql = new Sql;
|
||||||
var result = sql.execute("delete from log where action = 'main' and " +
|
var result = sql.execute(Sql.PURGEREFERRERS);
|
||||||
"created < date_add(now(), interval -2 day)");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +418,6 @@ Admin.prototype.update = function(data) {
|
||||||
probationPeriod: data.probationPeriod,
|
probationPeriod: data.probationPeriod,
|
||||||
quota: data.quota
|
quota: data.quota
|
||||||
});
|
});
|
||||||
this.log(root, "Updated setup");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ Comment.remove = function(options) {
|
||||||
}
|
}
|
||||||
if (options && options.mode === "user" && options.confirm === "1") {
|
if (options && options.mode === "user" && options.confirm === "1") {
|
||||||
var sql = new Sql;
|
var sql = new Sql;
|
||||||
sql.retrieve("select id from content where site_id = $0 and creator_id = $1 \
|
sql.retrieve(Sql.COMMENTS, this.site._id, this.creator._id);
|
||||||
and prototype = 'Comment'", this.site._id, this.creator._id);
|
|
||||||
sql.traverse(function() {
|
sql.traverse(function() {
|
||||||
Comment.remove.call(Comment.getById(this.id));
|
Comment.remove.call(Comment.getById(this.id));
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,7 +64,6 @@ String.URLPATTERN = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF90
|
||||||
|
|
||||||
// FIXME: Be careful with property names of app.data;
|
// FIXME: Be careful with property names of app.data;
|
||||||
// they inherit all properties from HopObject!
|
// they inherit all properties from HopObject!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name app.data
|
* @name app.data
|
||||||
* @namespace
|
* @namespace
|
||||||
|
@ -82,7 +81,6 @@ app.data.exports || (app.data.exports = []);
|
||||||
/** @name app.data.imports */
|
/** @name app.data.imports */
|
||||||
app.data.imports || (app.data.imports = []);
|
app.data.imports || (app.data.imports = []);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name helma.File
|
* @name helma.File
|
||||||
* @namespace
|
* @namespace
|
||||||
|
@ -146,15 +144,37 @@ jala.i18n.setLocaleGetter(function() {
|
||||||
return (res.handlers.site || root).getLocale();
|
return (res.handlers.site || root).getLocale();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @constant */
|
||||||
|
Sql.COMMENTS = "select id from content where site_id = $0 and creator_id = $1 \
|
||||||
|
and prototype = 'Comment'";
|
||||||
|
|
||||||
|
/** @constant */
|
||||||
|
Sql.PURGEREFERRERS = "delete from log where action = 'main' and " +
|
||||||
|
"created < date_add(now(), interval -2 day)";
|
||||||
|
|
||||||
|
/** @constant */
|
||||||
|
Sql.REFERRERS = "select referrer, count(*) as requests from " +
|
||||||
|
"log where context_type = '$0' and context_id = $1 and action = " +
|
||||||
|
"'main' and created > date_add(now(), interval -1 day) group " +
|
||||||
|
"by referrer order by requests desc, referrer asc";
|
||||||
|
|
||||||
|
/** @constant */
|
||||||
|
Sql.SEARCH = "select id from content where site_id = $0 and " +
|
||||||
|
"prototype = $1 and status <> $2 and (metadata like $3 or " +
|
||||||
|
"metadata like $4) order by created desc limit $5";
|
||||||
|
|
||||||
/** @constant */
|
/** @constant */
|
||||||
var SHORTDATEFORMAT = "yyyy-MM-dd HH:mm";
|
var SHORTDATEFORMAT = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
/** @constant */
|
/** @constant */
|
||||||
var LONGDATEFORMAT = "EEEE, d. MMMM yyyy, HH:mm";
|
var LONGDATEFORMAT = "EEEE, d. MMMM yyyy, HH:mm";
|
||||||
|
|
||||||
/** @constant */
|
/** @constant */
|
||||||
var SQLDATEFORMAT = "yyyy-MM-dd HH:mm:ss";
|
var SQLDATEFORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
/** @function */
|
/** @function */
|
||||||
var idle = new Function;
|
var idle = new Function;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
var html = new helma.Html();
|
var html = new helma.Html();
|
||||||
|
|
||||||
|
|
|
@ -567,11 +567,8 @@ Site.prototype.search_action = function() {
|
||||||
search = String(search).toSource().slice(13, -3).replace(/(\\)/g, "$1$1");
|
search = String(search).toSource().slice(13, -3).replace(/(\\)/g, "$1$1");
|
||||||
var title = '%title:"%' + search + '%"%';
|
var title = '%title:"%' + search + '%"%';
|
||||||
var text = '%text:"%' + search + '%"%';
|
var text = '%text:"%' + search + '%"%';
|
||||||
var sql = new Sql();
|
var sql = new Sql;
|
||||||
sql.retrieve("select id from content where site_id = $0 and " +
|
sql.retrieve(Sql.SEARCH, this._id, "Story", Story.CLOSED, text, title, 25);
|
||||||
"prototype = $1 and status <> $2 and (metadata like $3 or " +
|
|
||||||
"metadata like $4) order by created desc limit $5",
|
|
||||||
this._id, "Story", Story.CLOSED, text, title, 25);
|
|
||||||
res.push();
|
res.push();
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
sql.traverse(function() {
|
sql.traverse(function() {
|
||||||
|
@ -734,11 +731,8 @@ Site.prototype.deleted_macro = function() {
|
||||||
*/
|
*/
|
||||||
Site.prototype.referrers_macro = function() {
|
Site.prototype.referrers_macro = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var sql = new Sql();
|
var sql = new Sql;
|
||||||
sql.retrieve("select referrer, count(*) as requests from " +
|
sql.retrieve(Sql.REFERRERS, "Site", this._id);
|
||||||
"log where context_type = 'Site' and context_id = $0 and action = " +
|
|
||||||
"'main' and created > date_add(now(), interval -1 day) group " +
|
|
||||||
"by referrer order by requests desc, referrer asc", this._id);
|
|
||||||
sql.traverse(function() {
|
sql.traverse(function() {
|
||||||
if (this.requests && this.referrer) {
|
if (this.requests && this.referrer) {
|
||||||
this.text = encode(this.referrer.head(50));
|
this.text = encode(this.referrer.head(50));
|
||||||
|
|
|
@ -524,11 +524,8 @@ Story.prototype.referrers_macro = function(param, limit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var sql = new Sql();
|
var sql = new Sql;
|
||||||
sql.retrieve("select referrer, count(*) as requests from " +
|
sql.retrieve(Sql.REFERRERS, "Story", this._id);
|
||||||
"log where context_type = 'Story' and context_id = $0 and action = " +
|
|
||||||
"'main' and created > date_add(now(), interval -1 day) group " +
|
|
||||||
"by referrer order by requests desc, referrer asc", this._id);
|
|
||||||
|
|
||||||
res.push();
|
res.push();
|
||||||
var n = 0;
|
var n = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue