Commit 5354884f authored by 段英荣's avatar 段英荣

modify

parent 2170adf6
...@@ -45,25 +45,21 @@ function red() { ...@@ -45,25 +45,21 @@ function red() {
LAST_RESULT_FILE="last_total_num.txt" LAST_RESULT_FILE="last_total_num.txt"
last_total_num=0 last_total_num=0
if [[ -e $LAST_RESULT_FILE ]]:then if [[ -e $LAST_RESULT_FILE ]];then
cat $LAST_RESULT_FILE > $last_total_num last_total_num=`cat $LAST_RESULT_FILE`
fi fi
SQL="select count(1) from api_wordrelsynonym"
results=(`mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DB -e "$SQL"`)
new_total_num=${results[1]}
new_total_num=0 echo "new_total_num:"$new_total_num
SQL="select count(1) from api_wordrelsynonym group by wordrel_id" echo "last_total_num:"$last_total_num
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DB -e "$SQL" | while IFS= read -r ROW
do
if [[ $Counter -ge $linestoskip ]]; then
$new_total_num=$ROW
fi
done
Counter=0 Counter=0
$FILE="dynamic_synonym.txt" FILE="dynamic_synonym.txt"
$DICFILE="dynamic_synonym.dic" DICFILE="dynamic_synonym.dic"
if [[ -e $FILE ]];then if [[ -e $FILE ]];then
rm $FILE rm $FILE
...@@ -74,6 +70,7 @@ if [[ -e $DICFILE ]];then ...@@ -74,6 +70,7 @@ if [[ -e $DICFILE ]];then
fi fi
if [[ $last_total_num != $new_total_num ]];then if [[ $last_total_num != $new_total_num ]];then
echo "begin generate dynamic file..."
SQL="SELECT GROUP_CONCAT(word SEPARATOR ',') FROM api_wordrelsynonym GROUP BY wordrel_id" SQL="SELECT GROUP_CONCAT(word SEPARATOR ',') FROM api_wordrelsynonym GROUP BY wordrel_id"
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DB -e "$SQL" | while IFS= read -r ROW mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DB -e "$SQL" | while IFS= read -r ROW
do do
...@@ -90,4 +87,3 @@ if [[ $last_total_num != $new_total_num ]];then ...@@ -90,4 +87,3 @@ if [[ $last_total_num != $new_total_num ]];then
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment