s4
changeset 1004:70d9e8f1a85a
Show user's post count in the blog table of group home
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 29 Jan 2023 14:38:28 +0900 |
parents | 5bd1b5125049 |
children | c2fc7a148d2c |
files | s4-funcs.sh |
diffstat | 1 files changed, 17 insertions(+), 11 deletions(-) [+] |
line diff
1.1 --- a/s4-funcs.sh Sun Dec 11 17:19:32 2022 +0859 1.2 +++ b/s4-funcs.sh Sun Jan 29 14:38:28 2023 +0900 1.3 @@ -2942,6 +2942,7 @@ 1.4 frzbtn='<button class="toggle-frozen"></button>' 1.5 DT_CHLD=article:blogid \ 1.6 DT_QOWNER="$qgrp" \ 1.7 + DT_COUNT=author DT_COUNT_HEADER="書" DT_COUNT_BY=$user \ 1.8 DT_VIEW=replyblog dumptable html blog \ 1.9 "ctime title heading team notify:通知$colmd $colstate" "$cond" \ 1.10 | if [ -n "$iamowner" ] 1.11 @@ -3869,7 +3870,7 @@ 1.12 sqlfile=$tmpd/dump.sql 1.13 : > $sqlfile # ensure to be empty 1.14 printf '.mode html\n.header 1\n' > $sqlfile 1.15 - # $DT_CHLD=ChildTable:BindColumn 1.16 + # $DT_CHLD=ChildTable:BindColumn (eg. article:blogid) 1.17 if [ -n "$DT_CHLD" ]; then 1.18 _t=${DT_CHLD%:*} _i=${DT_CHLD#*:} 1.19 cat<<-EOF >> $sqlfile 1.20 @@ -3878,6 +3879,16 @@ 1.21 SELECT * FROM acclog WHERE user='$user' and tbl='$2'; 1.22 EOF 1.23 # Speed up counting of new articles 1.24 + dt_count=${DT_COUNT:+"CREATE TEMPORARY VIEW _dtcount AS 1.25 + SELECT a.id $_i, $DT_COUNT, coalesce(cnt2, 0) cnt2 1.26 + FROM (SELECT DISTINCT id FROM _target) a 1.27 + LEFT JOIN 1.28 + (SELECT blogid,$DT_COUNT,count($DT_COUNT) cnt2 1.29 + FROM $_t 1.30 + WHERE $DT_COUNT = '$DT_COUNT_BY' 1.31 + GROUP BY $_i,$DT_COUNT) b 1.32 + ON a.id=b.$_i 1.33 + ;"} 1.34 cat<<-EOF >> $sqlfile 1.35 -- presql2 1.36 DROP TABLE IF EXISTS _counts; 1.37 @@ -3915,19 +3926,14 @@ 1.38 '1970-01-01') 1.39 GROUP BY $_i) b 1.40 ON a.id=b.$_i; 1.41 + $dt_count 1.42 EOF 1.43 - # REMOVE next line until 2019/5/1 1.44 - cntall="(select count($_i) from $_t where $_i=a.id)" 1.45 cntall="(coalesce((select cnt from _counts where $_i=a.id), 0))" 1.46 - # REMOVE next assignment until 2019/5/1 1.47 - cntnew="(select count(val) from ${_t}_s where key='ctime' \ 1.48 - and id in (select id from $_t where $_i=a.id) \ 1.49 - and val > coalesce((select time from myacclog where \ 1.50 - tblrowid=a.rowid),\ 1.51 - '1970-01-01'))" 1.52 cntnew="(SELECT newcnt FROM _news where $_i=a.id)" 1.53 - cnt="$cntnew as '新着', $cntall as '総数'," 1.54 - dt_class=" td2r td3r dumpblogs" 1.55 + cntmine=${DT_COUNT:+"(SELECT cnt2 FROM _dtcount WHERE $_i=a.id)"} 1.56 + cnt="$cntnew as '新着', $cntall as '総数', " 1.57 + cnt=$cnt${DT_COUNT:+"$cntmine as '$DT_COUNT_HEADER',"} 1.58 + dt_class=" td2r td3r td4r dumpblogs" 1.59 fi 1.60 # Construct join expression 1.61 eav="" scols=""