Skip to content
Permalink
Browse files

XML interface and rating fixes and changes; updates #244

- XML interface update to v1.4
-- added listing_last_modified and log_last_modified fields
-- changed and fixed handling of ratings for multiple found logs of one user
-- resend log records after editing (only) rating or withdrawing rating via mytop5
-- logtype fix: convert type > 8 to 3 in XML versions < 1.3

- fixed rating handling when deleting one of multiple found logs
-- added dbmaintain update procedure for this fix
- show only one rating star when a user logged multiple founds
- added trigger update function to database versioning
  • Loading branch information...
following5 committed Jun 23, 2013
1 parent 373e922 commit 371894d177a6c66d2f08ac8391313150e80f4800
@@ -44,6 +44,20 @@
} while ($db_version > 0);
// Now and then a maintain.php update should be inserted, because multiple
// mutations may be run in one batch, and future mutations may depend on
// changed triggers, which may not be obvious.
// Of course, a trigger update mutation can also be inserted directly before a
// mutation which needs it. (But take care that maintain.php at that point does
// not depend on database changes which will be done by that mutation ...)
function update_triggers()
{
global $opt;
system('php ' . $opt['rootpath'] . 'doc/sql/stored-proc/maintain.php');
}
// Database mutations
// - must be consecutively numbered
// - should behave well if run multiple times
@@ -246,4 +260,9 @@ function dbv_112() // added maintained GC waypoints
sql("ALTER TABLE `caches` ADD INDEX `wp_gc_maintained` (`wp_gc_maintained`)");
}
function dbv_113() // preventive trigger update
{
update_triggers();
}
?>
@@ -27,6 +27,7 @@
$procedures[] = 'sp_updateall_cachelog_picturestat';
$procedures[] = 'sp_updateall_cache_listingdates';
$procedures[] = 'sp_updateall_cachelog_logdates';
$procedures[] = 'sp_updateall_rating_dates';
$tpl->assign('procedures', $procedures);
@@ -58,6 +59,8 @@
sql("CALL sp_updateall_cache_listingdates(@c)");
else if ($proc == 'sp_updateall_cachelog_logdates')
sql("CALL sp_updateall_cachelog_logdates(@c)");
else if ($proc == 'sp_updateall_rating_dates')
sql("CALL sp_updateall_rating_dates(@c)");
else
{
$bError = true;
@@ -2507,6 +2507,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2086', 'unknown
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2087', 'Show on map', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2089', 'disabled[pl]', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2090', 'archived[pl]', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2091', 'Test for and fix inconsistencies in database tables', '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 ('670', 'DE', 'Trefferquote', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('671', 'DE', 'Es können keine Empfehlungen gegeben werden, da keine weiteren Bewertungen vorliegen.', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('672', 'DE', 'Datenbankwartung', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('673', 'DE', 'DB Maintainance', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('673', 'DE', 'Datenbankwartung', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('674', 'DE', '%1 hat %2 Einträge korrigiert', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('675', 'DE', 'Ausführen', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('676', 'DE', 'Senden', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2087', 'DE', 'auf Karte anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2089', 'DE', 'deaktivierte', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2090', 'DE', 'archivierte', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2091', 'DE', 'Sucht und behebt Inkonsistenzen in Datenbanktabellen', '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');
@@ -8,7 +8,7 @@
***************************************************************************/
$opt['rootpath'] = '../../../';
$opt['rootpath'] = dirname(__FILE__) . '/../../../';
require_once($opt['rootpath'] . 'lib/clicompatbase.inc.php');
if (!file_exists($opt['rootpath'] . 'util/mysql_root/sql_root.inc.php'))
@@ -252,6 +252,17 @@
SET nModified = nModified + ROW_COUNT();
END;");
/* update log modification date when rating changed, so that it is resent via
XML interface; see issue #244 */
sql_dropProcedure('sp_update_cachelog_rating');
sql("CREATE PROCEDURE sp_update_cachelog_rating (IN nCacheId INT, IN nUserID INT, IN dRatingDate DATETIME)
BEGIN
IF (ISNULL(@XMLSYNC) OR @XMLSYNC!=1) THEN
UPDATE `cache_logs` SET `last_modified`=NOW()
WHERE `cache_logs`.`cache_id`=nCacheId AND `cache_logs`.`user_id`=nUserID AND `cache_logs`.`date`=dRatingDate;
END IF;
END;");
// set caches.desc_languages of given cacheid and fill cache_desc_prefered
sql_dropProcedure('sp_update_caches_descLanguages');
sql("CREATE PROCEDURE sp_update_caches_descLanguages (IN nCacheId INT(10) UNSIGNED)
@@ -515,6 +526,19 @@
SET nModified=nModified+ROW_COUNT();
END;");
// Update out-of-sync rating dates. These probably were caused by rating-related
// bugs when deleting one of multiple found logs and when changing the log type
// (9 mismatches within ~9 months up to June 2013).
sql_dropProcedure('sp_updateall_rating_dates');
sql("CREATE PROCEDURE sp_updateall_rating_dates (OUT nModified INT)
BEGIN
UPDATE `cache_rating` SET `rating_date` =
(SELECT `date` FROM `cache_logs` WHERE `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id` AND `cache_logs`.`type` IN (1,7) ORDER BY `date` LIMIT 1)
WHERE (SELECT COUNT(*) FROM `cache_logs` WHERE `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id` AND `cache_logs`.`date`=`cache_rating`.`rating_date` AND `type` IN (1,7))=0;
/* will set rating_date to 0000-00...:00 for orphan records */
SET nModified=ROW_COUNT();
END;");
// notify users with matching watch radius about this cache
sql_dropProcedure('sp_notify_new_cache');
sql("CREATE PROCEDURE sp_notify_new_cache (IN nCacheId INT(10) UNSIGNED, IN nLongitude DOUBLE, IN nLatitude DOUBLE)
@@ -966,6 +990,7 @@
FOR EACH ROW
BEGIN
CALL sp_update_topratingstat(NEW.`cache_id`, FALSE);
CALL sp_update_cachelog_rating(NEW.`cache_id`, NEW.`user_id`, NEW.`rating_date`);
END;");
sql_dropTrigger('cacheRatingAfterUpdate');
@@ -975,6 +1000,8 @@
IF NEW.`cache_id`!=OLD.`cache_id` THEN
CALL sp_update_topratingstat(OLD.`cache_id`, TRUE);
CALL sp_update_topratingstat(NEW.`cache_id`, FALSE);
CALL sp_update_cachelog_rating(OLD.`cache_id`, OLD.`user_id`, OLD.`rating_date`);
CALL sp_update_cachelog_rating(NEW.`cache_id`, NEW.`user_id`, NEW.`rating_date`);
END IF;
END;");
@@ -983,6 +1010,7 @@
FOR EACH ROW
BEGIN
CALL sp_update_topratingstat(OLD.`cache_id`, TRUE);
CALL sp_update_cachelog_rating(OLD.`cache_id`, OLD.`user_id`, OLD.`rating_date`);
END;");
sql_dropTrigger('cacheVisitsBeforeInsert');
Oops, something went wrong.

0 comments on commit 371894d

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