|
def | isStatisticEnabled (queryCallback, siteId, defValue, propName) |
|
def | addNewRecord (queryCallback, siteId, URLMd5) |
|
def | statisticUpdate (queryCallback, freqName, addValue, siteId, URLMd5) |
|
def | logUpdate (queryCallback, opName, logObject, siteId, URLMd5, opDate="NOW()") |
|
Definition at line 17 of file StatisticLogManager.py.
◆ addNewRecord()
def dc_db.StatisticLogManager.StatisticLogManager.addNewRecord |
( |
|
queryCallback, |
|
|
|
siteId, |
|
|
|
URLMd5 |
|
) |
| |
|
static |
Definition at line 45 of file StatisticLogManager.py.
45 def addNewRecord(queryCallback, siteId, URLMd5):
46 if queryCallback
is not None:
47 SQL_INSERT_TEMPLAE =
"INSERT IGNORE INTO `%s` SET `URLMd5`= '%s'" 48 if StatisticLogManager.isStatisticEnabled(queryCallback, siteId, StatisticLogManager.GLOBAL_FREQ_ENABLED,
49 StatisticLogManager.SITE_PROP_NAME_FREQ):
50 tbName = Constants.DC_FREQ_TABLE_NAME_TEMPLATE % siteId
51 query = SQL_INSERT_TEMPLAE % (tbName, URLMd5)
52 queryCallback(query, Constants.STAT_DB_ID)
54 logger.debug(
">>> Statistic Freq Disabled, SiteId=" + siteId)
56 logger.error(
">>> addNewRecord error, queryCallback is None")
◆ isStatisticEnabled()
def dc_db.StatisticLogManager.StatisticLogManager.isStatisticEnabled |
( |
|
queryCallback, |
|
|
|
siteId, |
|
|
|
defValue, |
|
|
|
propName |
|
) |
| |
|
static |
Definition at line 30 of file StatisticLogManager.py.
30 def isStatisticEnabled(queryCallback, siteId, defValue, propName):
33 tempValue = BaseTask.readValueFromSiteProp(siteId, propName, queryCallback)
34 if tempValue
is not None:
35 ret = bool(int(tempValue))
◆ logUpdate()
def dc_db.StatisticLogManager.StatisticLogManager.logUpdate |
( |
|
queryCallback, |
|
|
|
opName, |
|
|
|
logObject, |
|
|
|
siteId, |
|
|
|
URLMd5, |
|
|
|
opDate = "NOW()" |
|
) |
| |
|
static |
Definition at line 93 of file StatisticLogManager.py.
93 def logUpdate(queryCallback, opName, logObject, siteId, URLMd5, opDate="NOW()
"): if StatisticLogManager.isStatisticEnabled(queryCallback, siteId, StatisticLogManager.GLOBAL_LOG_ENABLED,
94 StatisticLogManager.SITE_PROP_NAME_LOG):
95 if queryCallback
is not None:
96 if opName
in Constants.logOperationsDict:
97 LOG_INSERT_SQL_TEMPLATE =
"INSERT INTO `%s` SET `URLMd5`='%s', `OpCode`=%s, `Object`='%s', `ODate`=%s" 98 tbName = Constants.DC_LOG_TABLE_NAME_TEMPLATE % siteId
100 if logObject
is not None:
102 objectStr = logObject.toJSON()
104 objectStr = Utils.escape(objectStr)
105 except Exception
as ex:
106 logger.debug(
">>> logUpdate Object to JSON error = " + str(ex))
107 if opDate !=
"NOW()":
108 opDate = (
"'" + opDate +
"'")
109 query = LOG_INSERT_SQL_TEMPLATE % (tbName, URLMd5, str(Constants.logOperationsDict[opName]), objectStr,
111 queryCallback(query, Constants.LOG_DB_ID)
113 logger.error(
">>> logUpdate error = " + str(opName) +
" Log field not support !")
115 logger.error(
">>> logUpdate error, queryCallback is None")
117 logger.debug(
">>> Statistic Log Disabled, SiteId=" + siteId)
◆ statisticUpdate()
def dc_db.StatisticLogManager.StatisticLogManager.statisticUpdate |
( |
|
queryCallback, |
|
|
|
freqName, |
|
|
|
addValue, |
|
|
|
siteId, |
|
|
|
URLMd5 |
|
) |
| |
|
static |
Definition at line 67 of file StatisticLogManager.py.
67 def statisticUpdate(queryCallback, freqName, addValue, siteId, URLMd5):
68 if StatisticLogManager.isStatisticEnabled(queryCallback, siteId, StatisticLogManager.GLOBAL_FREQ_ENABLED,
69 StatisticLogManager.SITE_PROP_NAME_FREQ):
70 if queryCallback
is not None:
71 if freqName
in Constants.StatFreqConstants.__dict__.values():
72 FREQ_UPDATE_SQL_TEMPLATE =
"UPDATE `%s` SET `%s`=`%s`+%s, `MDate`=NOW() WHERE `URLMd5`='%s'" 73 tbName = Constants.DC_FREQ_TABLE_NAME_TEMPLATE % siteId
74 query = FREQ_UPDATE_SQL_TEMPLATE % (tbName, freqName, freqName, str(addValue), URLMd5)
75 queryCallback(query, Constants.STAT_DB_ID)
77 logger.error(
">>> statisticUpdate error = " + str(freqName) +
" Statistic Freq field not support !")
79 logger.error(
">>> statisticUpdate error, queryCallback is None")
81 logger.debug(
">>> Statistic Freq Disabled, SiteId=" + siteId)
◆ GLOBAL_FREQ_ENABLED
bool dc_db.StatisticLogManager.StatisticLogManager.GLOBAL_FREQ_ENABLED = False |
|
static |
◆ GLOBAL_LOG_ENABLED
bool dc_db.StatisticLogManager.StatisticLogManager.GLOBAL_LOG_ENABLED = False |
|
static |
◆ SITE_PROP_NAME_FREQ
string dc_db.StatisticLogManager.StatisticLogManager.SITE_PROP_NAME_FREQ = "STATS_FREQ_ENABLED" |
|
static |
◆ SITE_PROP_NAME_LOG
string dc_db.StatisticLogManager.StatisticLogManager.SITE_PROP_NAME_LOG = "STATS_LOG_ENABLED" |
|
static |
The documentation for this class was generated from the following file: