コード例 #1
0
    def by_aa(cls, aa):
        result = {}
        values = (DBSession.query(
            cls.name, cls.value, func.count(cls.value),
            cls.aaid).filter_by(aaid=aa.authorizable_attribute_id).group_by(
                cls.name, cls.value).all())
        for v in values:
            existent_list = result.get(v[0], [])
            existent_list.append({v[1]: v[2]})
            if v[2] >= aa.optional_k(v[0]):
                result[v[0]] = existent_list
        result["total"] = ValidatedCredentials.total_by_aaid(
            aa.authorizable_attribute_id)

        return result
コード例 #2
0
    def aggregate(cls):
        result = {}
        values = (DBSession.query(cls.name, cls.value, func.count(cls.value),
                                  cls.aaid).group_by(cls.name,
                                                     cls.value).all())
        for v in values:
            existent_list = result.get(v[0], [])
            existent_list.append({v[1]: v[2]})
            aa = AuthorizableAttribute.by_aa_id(v[3])
            if v[2] >= aa.optional_k(v[0]):
                result[v[0]] = existent_list

        result["total"] = ValidatedCredentials.total()

        return result
コード例 #3
0
 def total(cls):
     return DBSession.query(cls).count()
コード例 #4
0
 def exists(cls, aaid, value):
     return (DBSession.query(cls).filter_by(aaid=aaid).filter_by(
         value=json.dumps(value)).first())
コード例 #5
0
 def by_aa_id(cls, aa_id):
     return DBSession.query(cls).filter_by(
         authorizable_attribute_id=aa_id).first()
コード例 #6
0
 def total_by_aaid(cls, aaid):
     return DBSession.query(cls).filter_by(aaid=aaid).count()