Mercurial > hgrepos > hgweb.cgi > s4
changeset 835:fa23017ba273
Sync only latest entries in user_m
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 23 Jun 2020 12:47:34 +0900 |
parents | a87030974b99 |
children | b3516ee2bb4d |
files | s4-world.sh |
diffstat | 1 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-world.sh Tue Jun 23 11:14:44 2020 +0900 +++ b/s4-world.sh Tue Jun 23 12:47:34 2020 +0900 @@ -79,6 +79,24 @@ fi err "`gdate +%S.%3N` Starting account synchronization[$$]" + prevsync=`tail -1 $syncflag|colrm 20` # 2020-06-21 12:30:00 = 19cols + syncall=${db%.*}.syncall + err syncallfile=$syncall + if [ -e $syncall ]; then + rm -f "$syncall" + err "Force update user_m for all users" + else + case "$prevsync" in + [2-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]\ [012][0-9]:??:??) + SYNCCOND="WHERE name in (SELECT name FROM m.user_s WHERE key='wtime' AND val > '$prevsync')" + err synccond limited to \ + `query "SELECT DISTINCT name FROM m.user_s $SYNCCOND;"` + err "Touch $syncall (owner=`id -un`) to update all user_m." + ;; + *) + echo arere ;; + esac + fi ## num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF num=$(query <<EOF BEGIN; @@ -92,9 +110,10 @@ SELECT rowid,* FROM m.user_s; DELETE FROM main.user_m WHERE rowid NOT IN (SELECT rowid FROM m.user_m); REPLACE INTO main.user_m(rowid, name, key, type, val, bin) - SELECT rowid,* FROM m.user_m + SELECT rowid,* FROM m.user_m $SYNCCOND EXCEPT - SELECT rowid,* FROM main.user_m; + SELECT rowid,* FROM main.user_m $SYNCCOND + ; END; /* Compare user tables */