s4

changeset 247:d0984b8e9f4c

Use temp.view readableblogs instead of writing down where condition.
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 16 Jul 2016 11:15:42 +0859
parents de0a9f5cc1cf
children 99a350b3e283
files s4-funcs.sh
diffstat 1 files changed, 3 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/s4-funcs.sh	Tue Jul 12 10:04:34 2016 +0859
     1.2 +++ b/s4-funcs.sh	Sat Jul 16 11:15:42 2016 +0859
     1.3 @@ -1384,15 +1384,16 @@
     1.4  }
     1.5  listnewblogsql() { # $1=user
     1.6    cat<<EOF
     1.7 +`sql4readableblogs`
     1.8  with article_ctime as (
     1.9    select id,blogid,author,val ctime
    1.10    from article join article_s s using(id)
    1.11    where s.key='ctime'
    1.12  ), blog_title_owner as (
    1.13 -  select blog.rowid, id,
    1.14 +  select blg.rowid, id,
    1.15          max(case key when 'title' then val end) title,
    1.16          max(case key when 'owner' then val end) owner
    1.17 - from blog, blog_s using(id) group by id
    1.18 + from readableblogs blg, blog_s using(id) group by id
    1.19  ), acclog_user as (
    1.20    select * from acclog where user='$user' and tbl='blog'
    1.21  ), blogall as (
    1.22 @@ -1411,16 +1412,6 @@
    1.23   (select gecos from gecoses where name=bl.owner) gecos
    1.24   from blogall bl left join acclog_user l
    1.25        on bl.rowid=round(l.tblrowid)
    1.26 - where case when (select name from user where owner=name) is not null
    1.27 -             then 1 /* user's diary is always readable */
    1.28 -            when (select val from grp_s
    1.29 -                  where gname=owner and key='regmode') = 'moderated'
    1.30 -                 and -- moderated group and nonmember can't read, not counting
    1.31 -                 (select user from grp_mem
    1.32 -                  where gname=owner and user='$user') is null
    1.33 -             then 0
    1.34 -            else 1
    1.35 -       end
    1.36   group by bl.id
    1.37   having "新着" > 0 order by ctime desc, "新着" desc, bl.id
    1.38   limit 10;