utils.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:tunga-api 作者: tunga-io 项目源码 文件源码
def annotate_channel_queryset_with_latest_activity_at(queryset, user):
    return queryset.annotate(
        latest_activity_timestamp=Max('action_targets__timestamp'),
    ).annotate(
        latest_activity_at=Case(
            When(
                latest_activity_timestamp__isnull=True,
                then='created_at'
            ),
            When(
                latest_activity_timestamp__gt=F('created_at'),
                then='latest_activity_timestamp'
            ),
            default='created_at',
            output_field=DateTimeField()
        )
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号