Changeset 1334
- Timestamp:
- 03/13/08 00:48:02 (7 months ago)
- Files:
-
- trunk/wifidog-auth/CHANGELOG (modified) (1 diff)
- trunk/wifidog-auth/wifidog/classes/Content.php (modified) (3 diffs)
- trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php (modified) (2 diffs)
- trunk/wifidog-auth/wifidog/include/schema_validate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wifidog-auth/CHANGELOG
r1331 r1334 1 1 # $Id$ 2 2008-03-12 Benoit Grégoire <bock@step.polymtl.ca> 3 * Major performance improvement in content manager for content groups picking items with limits on how many times they can be displayed. 4 * Improve performance of Content::getLastDisplayedTimestamp(), will mostly show when using the RSS aggregator, especially when postgres has little memory 5 2 6 2008-03-06 Benoit Grégoire <bock@step.polymtl.ca> 3 7 * Fix #438. Not Node::getNumOnlineUsers() will count every users connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user. trunk/wifidog-auth/wifidog/classes/Content.php
r1308 r1334 1434 1434 $db = AbstractDb :: getObject(); 1435 1435 1436 $sql = "SELECT EXTRACT('epoch' FROM last_display_timestamp) as last_display_timestamp FROM content_display_log WHERE content_id='$this->id' $user_sql $node_sql ORDER BY last_display_timestamp DESC limit 1";1436 $sql = "SELECT EXTRACT('epoch' FROM MAX(last_display_timestamp)) as last_display_timestamp FROM content_display_log WHERE content_id='$this->id' $user_sql $node_sql"; 1437 1437 $db->execSqlUniqueRes($sql, $log_row, false); 1438 1438 if ($log_row != null) { … … 1523 1523 array ( 1524 1524 'isSimpleContent' 1525 )1525 ) 1526 1526 ); 1527 1527 $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); … … 1970 1970 'title' => _("Reusable content library"), 1971 1971 'url' => BASE_URL_PATH.htmlspecialchars("admin/generic_object_admin.php?object_class=Content&action=list") 1972 );1972 ); 1973 1973 } 1974 1974 trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php
r1320 r1334 495 495 /* There aren't enough elements to redisplay, We need new content */ 496 496 497 $sql_base = "SELECT content_group_element_id FROM content_group_element WHERE content_group_id='$this->id' \n";498 $sql_base .= $sql_time_restrictions;499 $sql = $sql_base;500 501 497 /*'YES' => "Content can be shown more than once", 'NO' => "Content can only be shown once", 'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node"*/ 502 498 $allow_repeat = $this->getAllowRepeat(); 503 499 if ($allow_repeat == 'NO') { 504 $sql_repeat = "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 500 $sql_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id') \n"; 501 $sql_repeat = " AND content_display_log.content_id IS NULL \n"; 505 502 } 506 503 elseif ($allow_repeat == 'ONCE_PER_NODE') { 507 $sql_repeat = "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id' AND node_id = '$node_id') \n"; 504 $sql_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id' AND content_display_log.node_id = '$node_id') \n"; 505 $sql_repeat = " AND content_display_log.content_id IS NULL \n"; 508 506 } else { 507 $sql_repeat_join = null; 509 508 $sql_repeat = null; 510 509 } 510 $sql = "SELECT content_group_element_id FROM content_group_element $sql_repeat_join WHERE content_group_id='$this->id' \n"; 511 $sql .= $sql_time_restrictions; 511 512 $sql .= $sql_repeat; 512 513 if ($sql_redisplay) { … … 541 542 if ($content_ordering_mode == 'PSEUDO_RANDOM') { 542 543 //Special case, first get only the rows that haven't been displayed before' 543 $sql_no_repeat = " AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 544 $db->execSql($sql_base . $sql_no_repeat, $element_rows, false); 544 $sql_no_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id') \n"; 545 $sql_no_repeat_and = " AND content_display_log.content_id IS NULL \n"; 546 $sql_no_repeat = "SELECT content_group_element_id FROM content_group_element $sql_no_repeat_join WHERE content_group_id='$this->id' $sql_no_repeat_and \n"; 547 548 $db->execSql($sql_no_repeat, $element_rows, false); 545 549 } 546 550 //Normal case, or there wasn't any undisplayed content in PSEUDO_RANDOM trunk/wifidog-auth/wifidog/include/schema_validate.php
r1316 r1334 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 5 8);50 define('REQUIRED_SCHEMA_VERSION', 59); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1313 1313 } 1314 1314 1315 $new_schema_version = 59; 1316 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1317 printUpdateVersion($new_schema_version); 1318 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1319 $sql .= "CREATE INDEX idx_content_display_log ON content_display_log (last_display_timestamp);\n"; 1320 } 1321 1315 1322 /* 1316 1323 $new_schema_version = ;
