コード例 #1
0
 def get_all_countries():
     query = (db.session.query(
         func.unnest(Project.country).label("country")).distinct().order_by(
             "country").all())
     tags_dto = TagsDTO()
     tags_dto.tags = [r[0] for r in query]
     return tags_dto
コード例 #2
0
    def get_all_campaigns():
        """ Get all campaign tags in DB """
        result = db.session.query(Tags.campaigns).filter(Tags.campaigns.isnot(None))

        dto = TagsDTO()
        dto.tags = [r for r, in result]
        return dto
コード例 #3
0
    def get_all_organisations():
        """ Get all org tags in DB """
        result = db.session.query(Tags.organisations).filter(
            Tags.organisations.isnot(None)
        )

        dto = TagsDTO()
        dto.tags = [r for r, in result]
        return dto
コード例 #4
0
 def get_all_campaign_tag(preferred_locale="en"):
     query = (db.session.query(
         Project.id, Project.campaign_tag, Project.private,
         Project.status).join(ProjectInfo).filter(
             ProjectInfo.locale.in_(
                 [preferred_locale,
                  "en"])).filter(Project.private is not True).filter(
                      Project.campaign_tag.isnot(None)).filter(
                          Project.campaign_tag != ""))
     query = query.distinct(Project.campaign_tag)
     query = query.order_by(Project.campaign_tag)
     tags_dto = TagsDTO()
     tags_dto.tags = [r[1] for r in query]
     return tags_dto