# -*- coding: utf-8 -*-

PAI2_HOME_API = (
    r"select "
    r"T1.group_id, T2.group_name, T2.group_default_avatar, T2.group_avatar, T2.group_from, T3.photo_id, "
    r"T3.photo_path, T3.has_watermark, T3.photo_w, T3.photo_h, T3.photo_thumbnail_path, T3.photo_thumbnail_w, T3.photo_thumbnail_h, "
    r"T3.photo_thumbnail2_path, T3.photo_thumbnail2_w, T3.photo_thumbnail2_h, T3.user_id, T3.nickname, T3.avatar, "
    r"T3.comment_num, T3.thumbup_num, T3.photo_from, T3.session_id, T3.nomark, T3.origin, T3.created_at, T3.lensman_photo_id, T3.lensman_type "
    r"from (select * from group_groupuserinfo where user_id='{user_id}' and user_status=1 and status=1) as T1 "
    r"left outer join group_groupinfo as T2 on T1.group_id = T2.group_id "
    r"left outer join group_groupphotoinfo as T3 on T1.group_id = T3.group_id and T3.id > T1.current_id "
    r"where T3.status = 1 "
    r"order by DATE(T3.created_at) desc, FIELD(T3.user_id, '{user_id}') desc, 7 * T3.thumbup_num + 3 * T3.comment_num desc, T3.id desc "
    r"limit {offset}, {rows};"
)

PAI2_HOME_WX_API = (
    r"select "
    r"T1.group_id, T2.group_name, T2.group_default_avatar, T2.group_avatar, T2.group_from, T3.photo_id, "
    r"T3.photo_path, T3.has_watermark, T3.photo_w, T3.photo_h, T3.photo_thumbnail_path, T3.photo_thumbnail_w, T3.photo_thumbnail_h, "
    r"T3.photo_thumbnail2_path, T3.photo_thumbnail2_w, T3.photo_thumbnail2_h, T3.user_id, T3.nickname, T3.avatar, "
    r"T3.comment_num, T3.thumbup_num, T3.photo_from, T3.session_id, T3.nomark, T3.origin, T3.created_at, T3.lensman_photo_id, T3.lensman_type "
    r"from (select * from group_groupuserinfo where user_id='{user_id}' and user_status=1 and status=1) as T1 "
    r"left outer join group_groupinfo as T2 on T1.group_id = T2.group_id "
    r"left outer join group_groupphotoinfo as T3 on T1.group_id = T3.group_id and T3.id > T1.current_id "
    r"where T3.status = 1 "
    r"order by T3.id desc "
    r"limit {offset}, {rows};"
)
