def METHOD_NAME():
    attachment_subq = db.aliased(Attachment, get_attachment_query().subquery('attachment'))
    return {
        'num_active': get_attachment_query().count(),
        'num_total': AttachmentFile.query.join(Attachment, AttachmentFile.attachment_id == Attachment.id).count(),
        'size_active': (
            db.session.query(db.func.sum(AttachmentFile.size))
            .filter(AttachmentFile.id == attachment_subq.file_id)
            .scalar() or 0
        ),
        'size_total': (
            db.session.query(db.func.sum(AttachmentFile.size))
            .join(Attachment, AttachmentFile.attachment_id == Attachment.id)
            .scalar() or 0
        )
    }