Skip to content
Permalink
Browse files

do not count invisible caches in hidden stats

  • Loading branch information...
following
following committed Apr 28, 2013
1 parent 62acaf6 commit a3ea98874cf2aa7c92ee34d9cafb3a8035c70edf
@@ -106,4 +106,11 @@ function dbv_101() // add fields for fixing OKAPI issue #232
}
}
function dbv_102() // remove invisible caches from users' hidden stats
{
sql("INSERT IGNORE INTO `stat_user` (`user_id`) SELECT `user_id` FROM `caches` GROUP BY `user_id`");
sql("UPDATE `stat_user`, (SELECT `user_id`, COUNT(*) AS `count` FROM `caches` INNER JOIN `cache_status` ON `cache_status`.`id`=`caches`.`status` AND `allow_user_view`=1 GROUP BY `user_id`) AS `tblHidden` SET `stat_user`.`hidden`=`tblHidden`.`count` WHERE `stat_user`.`user_id`=`tblHidden`.`user_id`");
sql("CALL sp_refreshall_statpic()");
}
?>
@@ -66,3 +66,4 @@ date commit ID change
2013-04-06 e281cfa changed cach_logs.date and cach_logs_archived.date type to datetime
2013-04-22 c989c00 added fields caches.meta_last_modified, cache_logs.log_last_modified,
cache_logs_archived.log_last_modified, and triggers
2013-04-28 updated triggers to calculate hidden stats
@@ -2442,6 +2442,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2001', 'Own log
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2002', 'Show all finds', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2003', 'Show all logs', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2004', 'active caches', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2005', 'Show active', '2013-04-25 23:00:00');

-- Table sys_trans_ref
SET NAMES 'utf8';
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2002', 'DE', 'alle Funde anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2003', 'DE', 'alle Logs anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2004', 'DE', 'aktive Caches', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2005', 'DE', 'aktive anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
@@ -370,16 +370,18 @@
// increment/decrement stat_user.hidden
sql_dropProcedure('sp_update_hiddenstat');
sql("CREATE PROCEDURE sp_update_hiddenstat (IN nUserId INT, IN bRemoved BOOLEAN)
sql("CREATE PROCEDURE sp_update_hiddenstat (IN nUserId INT, IN iStatus INT, IN bRemoved BOOLEAN)
BEGIN
DECLARE nHidden INT DEFAULT 1;
IF bRemoved = TRUE THEN SET nHidden = -1; END IF;
UPDATE `stat_user` SET `stat_user`.`hidden`=IF(`stat_user`.`hidden`+nHidden>0, `stat_user`.`hidden`+nHidden, 0) WHERE `stat_user`.`user_id`=nUserId;
IF ROW_COUNT() = 0 THEN
INSERT IGNORE INTO `stat_user` (`user_id`, `hidden`) VALUES (nUserId, IF(nHidden>0, nHidden, 0));
END IF;
IF (SELECT `allow_user_view` FROM `cache_status` WHERE `id`=iStatus) THEN
IF bRemoved = TRUE THEN SET nHidden = -1; END IF;
UPDATE `stat_user` SET `stat_user`.`hidden`=IF(`stat_user`.`hidden`+nHidden>0, `stat_user`.`hidden`+nHidden, 0) WHERE `stat_user`.`user_id`=nUserId;
IF ROW_COUNT() = 0 THEN
INSERT IGNORE INTO `stat_user` (`user_id`, `hidden`) VALUES (nUserId, IF(nHidden>0, nHidden, 0));
END IF;
CALL sp_refresh_statpic(nUserId);
CALL sp_refresh_statpic(nUserId);
END IF;
END;");
// recalc hidden of stat_user for all entries
@@ -391,7 +393,7 @@
INSERT IGNORE INTO `stat_user` (`user_id`) SELECT `user_id` FROM `caches` GROUP BY `user_id`;
/* stat_caches.hidden */
UPDATE `stat_user`, (SELECT `user_id`, COUNT(*) AS `count` FROM `caches` GROUP BY `user_id`) AS `tblHidden` SET `stat_user`.`hidden`=`tblHidden`.`count` WHERE `stat_user`.`user_id`=`tblHidden`.`user_id`;
UPDATE `stat_user`, (SELECT `user_id`, COUNT(*) AS `count` FROM `caches` INNER JOIN `cache_status` ON `cache_status`.`id`=`caches`.`status` AND `allow_user_view`=1 GROUP BY `user_id`) AS `tblHidden` SET `stat_user`.`hidden`=`tblHidden`.`count` WHERE `stat_user`.`user_id`=`tblHidden`.`user_id`;
SET nModified=nModified+ROW_COUNT();
CALL sp_refreshall_statpic();
@@ -618,7 +620,7 @@
INSERT IGNORE INTO `cache_countries` (`cache_id`, `date_created`, `country`)
VALUES (NEW.`cache_id`, NOW(), NEW.`country`);
CALL sp_update_hiddenstat(NEW.`user_id`, FALSE);
CALL sp_update_hiddenstat(NEW.`user_id`, NEW.`status`, FALSE);
IF NEW.`status`=1 THEN
CALL sp_notify_new_cache(NEW.`cache_id`, NEW.`longitude`, NEW.`latitude`);
@@ -711,9 +713,9 @@
/* logpw needs not to be saved */
/* for further explanation see restorecaches.php */
END IF;
IF NEW.`user_id`!=OLD.`user_id` THEN
CALL sp_update_hiddenstat(OLD.`user_id`, TRUE);
CALL sp_update_hiddenstat(NEW.`user_id`, FALSE);
IF NEW.`user_id`!=OLD.`user_id` OR NEW.`status`!=OLD.`status` THEN
CALL sp_update_hiddenstat(OLD.`user_id`, OLD.`status`, TRUE);
CALL sp_update_hiddenstat(NEW.`user_id`, NEW.`status`, FALSE);
END IF;
IF OLD.`status`=5 AND NEW.`status`=1 THEN
CALL sp_notify_new_cache(NEW.`cache_id`, NEW.`longitude`, NEW.`latitude`);
@@ -735,7 +737,7 @@
DELETE FROM `cache_countries` WHERE `cache_id`=OLD.`cache_id`;
DELETE FROM `cache_npa_areas` WHERE `cache_id`=OLD.`cache_id`;
DELETE FROM `caches_modified` WHERE `cache_id`=OLD.`cache_id`;
CALL sp_update_hiddenstat(OLD.`user_id`, TRUE);
CALL sp_update_hiddenstat(OLD.`user_id`, OLD.`status`, TRUE);
INSERT IGNORE INTO `removed_objects` (`localId`, `uuid`, `type`, `node`) VALUES (OLD.`cache_id`, OLD.`uuid`, 2, OLD.`node`);
SET @dont_update_listingdate=0;
@@ -983,7 +983,7 @@
$sql_innerjoin[] = '`cache_status` ON `caches`.`status`=`cache_status`.`id`';
if (isset($usr['userid']))
$sql_where[] = '(`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`=' . sql_escape($usr['userid']) . ')';
$sql_where[] = '(`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`=' . sql_escape($usr['userid']) . ' OR (`caches`.`status`<>5 AND '. sql_escape($login->admin & ADMIN_USER) . '>0))';
else
$sql_where[] = '`cache_status`.`allow_user_view`=1';
@@ -55,7 +55,7 @@
if ($record === false)
$tpl->error(ERROR_USER_NOT_EXISTS);
$active = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1' AND `status`=1", 0, $userid);
$active = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1' AND `status`=1", 0, $userid);
$rs = sql("SELECT IFNULL(`tt`.`text`, `p`.`name`) AS `name`, `u`.`option_value`, `u`.`option_id` AS `option_id`
FROM `profile_options` AS `p`
@@ -76,7 +76,8 @@
LEFT JOIN `cache_type` AS `t` ON `t`.`id`=`c`.`type`
LEFT JOIN `sys_trans` AS `st` ON `st`.`id`=`t`.`trans_id` AND `t`.`name`=`st`.`text`
LEFT JOIN `sys_trans_text` AS `tt` ON `st`.`id`=`tt`.`trans_id` AND `tt`.`lang`='&2'
WHERE `c`.`user_id`='&1'
LEFT JOIN `cache_status` ON `cache_status`.`id`=`c`.`status`
WHERE `c`.`user_id`='&1' AND `allow_user_view`='1'
GROUP BY `t`.`id`
ORDER BY `anzahl` DESC",
$userid,

0 comments on commit a3ea988

Please sign in to comment.
You can’t perform that action at this time.