# HG changeset patch # User HIROSE Yuuji # Date 1674970708 -32400 # Node ID 70d9e8f1a85a77de08b8b6413a29ea028e20c589 # Parent 5bd1b512504908bc9d1f52ec7345873bb2d7f53c Show user's post count in the blog table of group home diff -r 5bd1b5125049 -r 70d9e8f1a85a s4-funcs.sh --- a/s4-funcs.sh Sun Dec 11 17:19:32 2022 +0859 +++ b/s4-funcs.sh Sun Jan 29 14:38:28 2023 +0900 @@ -2942,6 +2942,7 @@ frzbtn='' DT_CHLD=article:blogid \ DT_QOWNER="$qgrp" \ + DT_COUNT=author DT_COUNT_HEADER="書" DT_COUNT_BY=$user \ DT_VIEW=replyblog dumptable html blog \ "ctime title heading team notify:通知$colmd $colstate" "$cond" \ | if [ -n "$iamowner" ] @@ -3869,7 +3870,7 @@ sqlfile=$tmpd/dump.sql : > $sqlfile # ensure to be empty printf '.mode html\n.header 1\n' > $sqlfile - # $DT_CHLD=ChildTable:BindColumn + # $DT_CHLD=ChildTable:BindColumn (eg. article:blogid) if [ -n "$DT_CHLD" ]; then _t=${DT_CHLD%:*} _i=${DT_CHLD#*:} cat<<-EOF >> $sqlfile @@ -3878,6 +3879,16 @@ SELECT * FROM acclog WHERE user='$user' and tbl='$2'; EOF # Speed up counting of new articles + dt_count=${DT_COUNT:+"CREATE TEMPORARY VIEW _dtcount AS + SELECT a.id $_i, $DT_COUNT, coalesce(cnt2, 0) cnt2 + FROM (SELECT DISTINCT id FROM _target) a + LEFT JOIN + (SELECT blogid,$DT_COUNT,count($DT_COUNT) cnt2 + FROM $_t + WHERE $DT_COUNT = '$DT_COUNT_BY' + GROUP BY $_i,$DT_COUNT) b + ON a.id=b.$_i + ;"} cat<<-EOF >> $sqlfile -- presql2 DROP TABLE IF EXISTS _counts; @@ -3915,19 +3926,14 @@ '1970-01-01') GROUP BY $_i) b ON a.id=b.$_i; + $dt_count EOF - # REMOVE next line until 2019/5/1 - cntall="(select count($_i) from $_t where $_i=a.id)" cntall="(coalesce((select cnt from _counts where $_i=a.id), 0))" - # REMOVE next assignment until 2019/5/1 - cntnew="(select count(val) from ${_t}_s where key='ctime' \ - and id in (select id from $_t where $_i=a.id) \ - and val > coalesce((select time from myacclog where \ - tblrowid=a.rowid),\ - '1970-01-01'))" cntnew="(SELECT newcnt FROM _news where $_i=a.id)" - cnt="$cntnew as '新着', $cntall as '総数'," - dt_class=" td2r td3r dumpblogs" + cntmine=${DT_COUNT:+"(SELECT cnt2 FROM _dtcount WHERE $_i=a.id)"} + cnt="$cntnew as '新着', $cntall as '総数', " + cnt=$cnt${DT_COUNT:+"$cntmine as '$DT_COUNT_HEADER',"} + dt_class=" td2r td3r td4r dumpblogs" fi # Construct join expression eav="" scols=""