Commit bd3a6629 authored by Dzahn's avatar Dzahn 🐲
Browse files

miraheze: do not delete old data until confirming new data was received

Add a rudimentary check if there are at least 3 wikis found
before doing anything.

Then actually simply skip the DELETE part because we already have
INSERT IGNORE lines here and a constraint that DB won't accept
duplicates in prefix column.

So we can just never delete and it works like an append.

Bug: T292369
Change-Id: Ief7f9c472ea9559d9d34621788ab08ce9bb4cc0a
parent 3f746a99
......@@ -13,8 +13,6 @@ if [ -f $OUTFILE ]; then
echo -e "DELETE from miraheze;" >> $OUTFILE
echo -e "importing miraheze wikis\n"
/usr/bin/php /usr/local/bin/wikistats/import_miraheze.php >> $OUTFILE
......@@ -23,9 +21,15 @@ echo -e "appended to $OUTFILE\n"
num_wikis=$(wc -l $OUTFILE | cut -d " " -f1)
echo -e "$num_wikis wikis detected. deleting table contents .. importing new data to mysql ..\n"
echo -e "$num_wikis wikis detected..\n"
/usr/bin/mysql -u root wikistats < $OUTFILE
if [ $num_wikis -gt 3 ]
/usr/bin/mysql -u root wikistats < $OUTFILE
echo -e "something seems to have failed with the import. check output file: ${OUTFILE}"
exit 1
echo -e "cleaning up temp files and starting regular table update script\n"
Supports Markdown
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