Mercurial > hgrepos > hgweb.cgi > s4
changeset 1004:70d9e8f1a85a draft
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 wrap: on
line diff
--- 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='<button class="toggle-frozen"></button>' 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=""