comparison s4-funcs.sh @ 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
comparison
equal deleted inserted replaced
1003:5bd1b5125049 1004:70d9e8f1a85a
2940 cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by 稼動状態, ctime desc" 2940 cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by 稼動状態, ctime desc"
2941 colstate="state:稼動状態:frozen=rowclass=凍結" 2941 colstate="state:稼動状態:frozen=rowclass=凍結"
2942 frzbtn='<button class="toggle-frozen"></button>' 2942 frzbtn='<button class="toggle-frozen"></button>'
2943 DT_CHLD=article:blogid \ 2943 DT_CHLD=article:blogid \
2944 DT_QOWNER="$qgrp" \ 2944 DT_QOWNER="$qgrp" \
2945 DT_COUNT=author DT_COUNT_HEADER="書" DT_COUNT_BY=$user \
2945 DT_VIEW=replyblog dumptable html blog \ 2946 DT_VIEW=replyblog dumptable html blog \
2946 "ctime title heading team notify:通知$colmd $colstate" "$cond" \ 2947 "ctime title heading team notify:通知$colmd $colstate" "$cond" \
2947 | if [ -n "$iamowner" ] 2948 | if [ -n "$iamowner" ]
2948 then 2949 then
2949 sed -Ee "s,(<TD class=\"稼動状態\">).*(</TD>),\1$frzbtn\2," 2950 sed -Ee "s,(<TD class=\"稼動状態\">).*(</TD>),\1$frzbtn\2,"
3867 dvlink=" <a href=\"$myname?$VIEW+\\2\\3\">VI</a><a href=\"$myname?$VIEW+\\2#bottom\">EW</a>" 3868 dvlink=" <a href=\"$myname?$VIEW+\\2\\3\">VI</a><a href=\"$myname?$VIEW+\\2#bottom\">EW</a>"
3868 fi 3869 fi
3869 sqlfile=$tmpd/dump.sql 3870 sqlfile=$tmpd/dump.sql
3870 : > $sqlfile # ensure to be empty 3871 : > $sqlfile # ensure to be empty
3871 printf '.mode html\n.header 1\n' > $sqlfile 3872 printf '.mode html\n.header 1\n' > $sqlfile
3872 # $DT_CHLD=ChildTable:BindColumn 3873 # $DT_CHLD=ChildTable:BindColumn (eg. article:blogid)
3873 if [ -n "$DT_CHLD" ]; then 3874 if [ -n "$DT_CHLD" ]; then
3874 _t=${DT_CHLD%:*} _i=${DT_CHLD#*:} 3875 _t=${DT_CHLD%:*} _i=${DT_CHLD#*:}
3875 cat<<-EOF >> $sqlfile 3876 cat<<-EOF >> $sqlfile
3876 -- presql 3877 -- presql
3877 CREATE TEMPORARY TABLE IF NOT EXISTS myacclog AS 3878 CREATE TEMPORARY TABLE IF NOT EXISTS myacclog AS
3878 SELECT * FROM acclog WHERE user='$user' and tbl='$2'; 3879 SELECT * FROM acclog WHERE user='$user' and tbl='$2';
3879 EOF 3880 EOF
3880 # Speed up counting of new articles 3881 # Speed up counting of new articles
3882 dt_count=${DT_COUNT:+"CREATE TEMPORARY VIEW _dtcount AS
3883 SELECT a.id $_i, $DT_COUNT, coalesce(cnt2, 0) cnt2
3884 FROM (SELECT DISTINCT id FROM _target) a
3885 LEFT JOIN
3886 (SELECT blogid,$DT_COUNT,count($DT_COUNT) cnt2
3887 FROM $_t
3888 WHERE $DT_COUNT = '$DT_COUNT_BY'
3889 GROUP BY $_i,$DT_COUNT) b
3890 ON a.id=b.$_i
3891 ;"}
3881 cat<<-EOF >> $sqlfile 3892 cat<<-EOF >> $sqlfile
3882 -- presql2 3893 -- presql2
3883 DROP TABLE IF EXISTS _counts; 3894 DROP TABLE IF EXISTS _counts;
3884 CREATE TEMPORARY TABLE _counts AS 3895 CREATE TEMPORARY TABLE _counts AS
3885 SELECT $_i, count($_i) cnt 3896 SELECT $_i, count($_i) cnt
3913 WHERE ctime > coalesce((SELECT time from myacclog 3924 WHERE ctime > coalesce((SELECT time from myacclog
3914 WHERE tblrowid=x.trowid), 3925 WHERE tblrowid=x.trowid),
3915 '1970-01-01') 3926 '1970-01-01')
3916 GROUP BY $_i) b 3927 GROUP BY $_i) b
3917 ON a.id=b.$_i; 3928 ON a.id=b.$_i;
3929 $dt_count
3918 EOF 3930 EOF
3919 # REMOVE next line until 2019/5/1
3920 cntall="(select count($_i) from $_t where $_i=a.id)"
3921 cntall="(coalesce((select cnt from _counts where $_i=a.id), 0))" 3931 cntall="(coalesce((select cnt from _counts where $_i=a.id), 0))"
3922 # REMOVE next assignment until 2019/5/1
3923 cntnew="(select count(val) from ${_t}_s where key='ctime' \
3924 and id in (select id from $_t where $_i=a.id) \
3925 and val > coalesce((select time from myacclog where \
3926 tblrowid=a.rowid),\
3927 '1970-01-01'))"
3928 cntnew="(SELECT newcnt FROM _news where $_i=a.id)" 3932 cntnew="(SELECT newcnt FROM _news where $_i=a.id)"
3929 cnt="$cntnew as '新着', $cntall as '総数'," 3933 cntmine=${DT_COUNT:+"(SELECT cnt2 FROM _dtcount WHERE $_i=a.id)"}
3930 dt_class=" td2r td3r dumpblogs" 3934 cnt="$cntnew as '新着', $cntall as '総数', "
3935 cnt=$cnt${DT_COUNT:+"$cntmine as '$DT_COUNT_HEADER',"}
3936 dt_class=" td2r td3r td4r dumpblogs"
3931 fi 3937 fi
3932 # Construct join expression 3938 # Construct join expression
3933 eav="" scols="" 3939 eav="" scols=""
3934 pk=`gettblpkey $2` 3940 pk=`gettblpkey $2`
3935 substr=${dumpcollen:+"substr(%s, 0, $dumpcollen)"} 3941 substr=${dumpcollen:+"substr(%s, 0, $dumpcollen)"}

yatex.org