s4

changeset 242:7dd85c224bbb

Fix NEWS sql
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 08 Jul 2016 19:26:09 +0859
parents 0c817d4a549a
children 466ea3e4b039
files s4-funcs.sh
diffstat 1 files changed, 8 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/s4-funcs.sh	Thu Jun 30 17:55:35 2016 +0859
     1.2 +++ b/s4-funcs.sh	Fri Jul 08 19:26:09 2016 +0859
     1.3 @@ -1388,38 +1388,31 @@
     1.4          max(case key when 'owner' then val end) owner
     1.5   from blog, blog_s using(id) group by id
     1.6  ), acclog_user as (
     1.7 -  -- select * from acclog where user='$user' and tbl='blog'
     1.8 -  -- GET (user,tbl,tblrowid,max(time,DEFAULTtime))
     1.9 -  SELECT user, tbl, tblrowid,
    1.10 -         max(time,
    1.11 -             coalesce((SELECT time FROM acclog
    1.12 -		       WHERE user='$user' and tbl='blog'
    1.13 -		       AND tblrowid=$blogreadflagrowid), " ")) time
    1.14 -	 FROM acclog
    1.15 -	 WHERE user='$user' AND  tbl='blog'
    1.16 +  select * from acclog where user='$user' and tbl='blog'
    1.17  ), blogall as (
    1.18   select b.id, b.rowid, b.owner, b.title, ctime, ac.author
    1.19   from blog_title_owner b, article_ctime ac
    1.20        on b.id=ac.blogid
    1.21  )
    1.22   select rowid LINK, 
    1.23 -        sum(case when l.time is not null
    1.24 -                 then l.time < ctime
    1.25 -                 else 1
    1.26 -            end) "新着",
    1.27 +        sum(max(coalesce(l.time, "0"),
    1.28 +		coalesce((SELECT time FROM acclog_user
    1.29 +		         WHERE tblrowid=$blogreadflagrowid), "0"))
    1.30 +	      < ctime
    1.31 +         ) "新着",
    1.32   count(id) "総数", ctime, title,
    1.33   /* owner gecos */
    1.34   (select gecos from gecoses where name=bl.owner) gecos
    1.35   from blogall bl left join acclog_user l
    1.36        on bl.rowid=round(l.tblrowid)
    1.37   where case when (select name from user where owner=name) is not null
    1.38 -            then 1 /* user's diary is always readable */
    1.39 +             then 1 /* user's diary is always readable */
    1.40              when (select val from grp_s
    1.41                    where gname=owner and key='regmode') = 'moderated'
    1.42                   and -- moderated group and nonmember can't read, not counting
    1.43                   (select user from grp_mem
    1.44                    where gname=owner and user='$user') is null
    1.45 -            then 0
    1.46 +             then 0
    1.47              else 1
    1.48         end
    1.49   group by bl.id