forked from xotab30/CinemaPress-ACMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCP_publish.js
73 lines (56 loc) · 1.52 KB
/
CP_publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
/**
* Configuration dependencies.
*/
var config = require('../config/production/config');
/**
* Formation of the query term.
*
* @param {Object} q
* @param {Object} [certainly]
* @return {Object}
*/
function queryConditionPublish(q, certainly) {
var where = (config.publish.required.length)
? config.publish.required.map(function (ctgry) {
return ' AND `' + ctgry.trim() + '` != \'\' ';
})
: [];
where = (where.length) ? where.join(' ') : '';
q._select = (certainly)
? ', ( ' +
'kp_id >= 1' +
' AND ' +
'kp_id <= 3000000' +
' ) AS movie '
: ', ( ' +
'kp_id >= ' + config.publish.start +
' AND ' +
'kp_id <= ' + config.publish.stop +
' ) AS movie';
q._where = ' AND movie > 0 ' + where;
return q;
}
/**
* Terms thematic site.
*
* @return {Object}
*/
function thematicPublish() {
var publish = {};
publish.where_config = [];
publish.match_config = [];
if (config.publish.thematic.type) {
publish.where_config.push('`type` = ' + parseInt(config.publish.thematic.type));
}
Object.keys(config.publish.thematic).forEach(function (key) {
if (config.publish.thematic[key] && key !== 'type') {
publish.match_config.push('@' + key + ' ' + config.publish.thematic[key]);
}
});
return publish;
}
module.exports = {
"queryCondition" : queryConditionPublish,
"thematic" : thematicPublish
};