1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-17 00:08:17 +03:00

удалена лишняя табличка + конвертер для стран и городов в новую структуру

This commit is contained in:
Mzhelskiy Maxim 2008-11-03 20:18:09 +00:00
parent b19286369d
commit 1045d67bf6
6 changed files with 83 additions and 59 deletions

View file

@ -664,15 +664,8 @@ class ActionBlog extends Action {
* Отмечаем дату прочтения топика
*/
if ($this->oUserCurrent) {
$this->Topic_SetDateRead($oTopic->getId(),$this->oUserCurrent->getId());
}
/**
* Запоминаем число комментов в топике для юзера, это понадобится при показе числа новых комментов
*/
if ($this->oUserCurrent) {
$this->Topic_SetCountCommentLast($oTopic->getId(),$this->oUserCurrent->getId(),$oTopic->getCountComment());
}
$this->Topic_SetDateRead($oTopic->getId(),$this->oUserCurrent->getId(),$oTopic->getCountComment());
}
/**
* Выставляем SEO данные
*/
@ -762,14 +755,8 @@ class ActionBlog extends Action {
* Отмечаем дату прочтения топика
*/
if ($this->oUserCurrent) {
$this->Topic_SetDateRead($oTopic->getId(),$this->oUserCurrent->getId());
}
/**
* Запоминаем число комментов в топике для юзера, это понадобится при показе числа новых комментов
*/
if ($this->oUserCurrent) {
$this->Topic_SetCountCommentLast($oTopic->getId(),$this->oUserCurrent->getId(),$oTopic->getCountComment());
}
$this->Topic_SetDateRead($oTopic->getId(),$this->oUserCurrent->getId(),$oTopic->getCountComment());
}
/**
* Выставляем SEO данные
*/

View file

@ -648,27 +648,13 @@ class Topic extends Module {
* @param unknown_type $sTopicId
* @param unknown_type $sUserId
*/
public function SetDateRead($sTopicId,$sUserId) {
$res=$this->oMapperTopic->SetDateRead($sTopicId,$sUserId);
public function SetDateRead($sTopicId,$sUserId,$iCountComment) {
$res=$this->oMapperTopic->SetDateRead($sTopicId,$sUserId,$iCountComment);
if ($res==1 or $res==2) {
return true;
}
return false;
}
/**
* Запоминаем число комментов при чтении топика
*
* @param unknown_type $sTopicId
* @param unknown_type $sUserId
* @param unknown_type $iCountComment
*/
public function SetCountCommentLast($sTopicId,$sUserId,$iCountComment) {
$res=$this->oMapperTopic->SetCountCommentLast($sTopicId,$sUserId,$iCountComment);
if ($res==1 or $res==2) {
return true;
}
return false;
}
}
/**
* Получаем дату прочтения топика юзером
*

View file

@ -283,7 +283,7 @@ class Mapper_Topic extends Mapper {
IF(tqv.topic_id IS NULL,0,1) as user_question_is_vote,
bu.is_moderator as user_is_blog_moderator,
bu.is_administrator as user_is_blog_administrator,
IF(tcl.comment_count_last IS NULL,t_fast.topic_count_comment,t_fast.topic_count_comment-tcl.comment_count_last) as count_comment_new
IF(tr.comment_count_last IS NULL,t_fast.topic_count_comment,t_fast.topic_count_comment-tr.comment_count_last) as count_comment_new
FROM (
SELECT
t.*,
@ -316,9 +316,9 @@ class Mapper_Topic extends Mapper {
SELECT
topic_id,
comment_count_last
FROM ".DB_TABLE_TOPIC_COMMENT_LAST."
FROM ".DB_TABLE_TOPIC_READ."
WHERE user_id = ?d
) AS tcl ON t_fast.topic_id=tcl.topic_id
) AS tr ON t_fast.topic_id=tr.topic_id
LEFT JOIN (
SELECT
topic_id
@ -913,29 +913,18 @@ class Mapper_Topic extends Mapper {
return $aReturn;
}
public function SetDateRead($sTopicId,$sUserId) {
public function SetDateRead($sTopicId,$sUserId,$iCountComment) {
$sDate=date("Y-m-d H:i:s");
$sql = "REPLACE ".DB_TABLE_TOPIC_READ."
SET
comment_count_last = ? ,
date_read = ? ,
topic_id = ? ,
user_id = ?
";
return $this->oDb->query($sql,$sDate,$sTopicId,$sUserId);
}
public function SetCountCommentLast($sTopicId,$sUserId,$iCountComment) {
$sDate=date("Y-m-d H:i:s");
$sql = "REPLACE INTO ".DB_TABLE_TOPIC_COMMENT_LAST."
SET
comment_count_last = ? ,
date_last = ? ,
user_id = ? ,
topic_id = ?
";
return $this->oDb->query($sql,$iCountComment,$sDate,$sUserId,$sTopicId);
}
return $this->oDb->query($sql,$iCountComment,$sDate,$sTopicId,$sUserId);
}
public function GetDateRead($sTopicId,$sUserId) {
$sql = "SELECT
date_read

View file

@ -43,7 +43,6 @@ define('DB_TABLE_USER_ADMINISTRATOR',DB_PREFIX_TABLE.'user_administrator');
define('DB_TABLE_TOPIC_COMMENT_ONLINE',DB_PREFIX_TABLE.'topic_comment_online');
define('DB_TABLE_INVITE',DB_PREFIX_TABLE.'invite');
define('DB_TABLE_PAGE',DB_PREFIX_TABLE.'page');
define('DB_TABLE_TOPIC_COMMENT_LAST',DB_PREFIX_TABLE.'topic_comment_last');
define('DB_TABLE_CITY',DB_PREFIX_TABLE.'city');
define('DB_TABLE_CITY_USER',DB_PREFIX_TABLE.'city_user');
define('DB_TABLE_COUNTRY',DB_PREFIX_TABLE.'country');

View file

@ -7,7 +7,7 @@ set_time_limit(0);
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__));
chdir(dirname(__FILE__));
require_once("./config/config.table.php");
require_once("./config/config.ajax.php");
$aConfig=include("./config/config.db.php");
@ -30,12 +30,14 @@ $sql = "SELECT
$res=mysql_query($sql,$link);
while ($row=mysql_fetch_assoc($res)) {
//var_dump($row);
$sql2 = "INSERT INTO ".DB_TABLE_TOPIC_CONTENT."
if (isset($row['topic_text'])) {
$sql2 = "REPLACE INTO ".DB_TABLE_TOPIC_CONTENT."
(topic_id,topic_text,topic_text_short,topic_text_source)
values(".$row['topic_id'].",'".mysql_escape_string($row['topic_text'])."','".mysql_escape_string($row['topic_text_short'])."','".mysql_escape_string($row['topic_text_source'])."')
";
mysql_query($sql2,$link);
";
mysql_query($sql2,$link);
}
}
*/
@ -43,6 +45,7 @@ while ($row=mysql_fetch_assoc($res)) {
* Конвертируем комментариии в новую структуру
* Если комментариев много, то может занять много времени
*/
/*
$sql = "SELECT res.* FROM (
SELECT
@ -89,4 +92,61 @@ while ($row=mysql_fetch_assoc($res)) {
";
mysql_query($sql2,$link);
}
*/
/**
* конвертируем страны и города в новую структуру
*/
$aData=$oEngine->User_GetUsersRating('good',0,1,10000);
$aUsers=$aData['collection'];
foreach ($aUsers as $oUser) {
/**
* Добавляем страну
*/
if ($oUser->getProfileCountry()) {
if (!($oCountry=$oEngine->User_GetCountryByName($oUser->getProfileCountry()))) {
$oCountry=new UserEntity_Country();
$oCountry->setName($oUser->getProfileCountry());
$oEngine->User_AddCountry($oCountry);
}
$oEngine->User_SetCountryUser($oCountry->getId(),$oUser->getId());
}
/**
* Добавляем город
*/
if ($oUser->getProfileCity()) {
if (!($oCity=$oEngine->User_GetCityByName($oUser->getProfileCity()))) {
$oCity=new UserEntity_City();
$oCity->setName($oUser->getProfileCity());
$oEngine->User_AddCity($oCity);
}
$oEngine->User_SetCityUser($oCity->getId(),$oUser->getId());
}
}
$aData=$oEngine->User_GetUsersRating('bad',0,1,10000);
$aUsers=$aData['collection'];
foreach ($aUsers as $oUser) {
/**
* Добавляем страну
*/
if ($oUser->getProfileCountry()) {
if (!($oCountry=$oEngine->User_GetCountryByName($oUser->getProfileCountry()))) {
$oCountry=new UserEntity_Country();
$oCountry->setName($oUser->getProfileCountry());
$oEngine->User_AddCountry($oCountry);
}
$oEngine->User_SetCountryUser($oCountry->getId(),$oUser->getId());
}
/**
* Добавляем город
*/
if ($oUser->getProfileCity()) {
if (!($oCity=$oEngine->User_GetCityByName($oUser->getProfileCity()))) {
$oCity=new UserEntity_City();
$oCity->setName($oUser->getProfileCity());
$oEngine->User_AddCity($oCity);
}
$oEngine->User_SetCityUser($oCity->getId(),$oUser->getId());
}
}
?>

View file

@ -317,7 +317,10 @@ ALTER TABLE `prefix_favourite_topic` ADD `topic_publish` TINYINT( 1 ) NOT NULL D
ALTER TABLE `prefix_favourite_topic` ADD INDEX ( `topic_publish` ) ;
-- удаляем табличку, она оказалась лишней :)
DROP TABLE `prefix_topic_comment_last` ;
-- новое поле для определения количества новых комментов
ALTER TABLE `prefix_topic_read` ADD `comment_count_last` INT UNSIGNED NOT NULL DEFAULT '0';
--
-- ВНИМАНИЕ!!! То что ниже нужно выполнить только после запуска скрипта convert.php !!!! иначе УДАЛЯТСЯ ВСЕ ТОПИКИ!!!!!