当前位置: 首页>>代码示例>>Python>>正文


Python Team.query方法代码示例

本文整理汇总了Python中models.team.Team.query方法的典型用法代码示例。如果您正苦于以下问题:Python Team.query方法的具体用法?Python Team.query怎么用?Python Team.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.team.Team的用法示例。


在下文中一共展示了Team.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self, page_num=0):
        self._require_admin()
        page_num = int(page_num)

        if page_num < self.MAX_PAGE:
            start = self.PAGE_SIZE * page_num
            end = start + self.PAGE_SIZE
            teams = Team.query(Team.team_number >= start, Team.team_number < end).order(Team.team_number).fetch()
        else:
            start = self.PAGE_SIZE * self.MAX_PAGE
            teams = Team.query(Team.team_number >= start).order(Team.team_number).fetch()

        page_labels = []
        for page in xrange(self.MAX_PAGE):
            if page == 0:
                page_labels.append('1-999')
            else:
                page_labels.append('{}\'s'.format(1000 * page))
        page_labels.append('{}+'.format(1000 * self.MAX_PAGE))

        self.template_values.update({
            "teams": teams,
            "num_teams": Team.query().count(),
            "page_num": page_num,
            "page_labels": page_labels,
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/admin/team_list.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:31,代码来源:admin_team_controller.py

示例2: _render

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def _render(self, page=''):
        page_labels = []
        for curPage in self.VALID_PAGES:
            if curPage == 1:
                label = '1-999'
            else:
                label = "{}'s".format((curPage - 1)*1000)
            page_labels.append(label)
            if curPage == page:
                cur_page_label = label
                                   
        start = (page - 1) * 1000
        stop = start + 999
        teams = Team.query().order(Team.team_number).filter(Team.team_number >= start).filter(Team.team_number < stop).fetch(10000)        

        num_teams = len(teams)
        middle_value = num_teams/2
        if num_teams%2 != 0:
            middle_value += 1
        teams_a, teams_b = teams[:middle_value], teams[middle_value:]

        template_values = {
            "teams_a": teams_a,
            "teams_b": teams_b,
            "num_teams": num_teams,
            "page_labels": page_labels,
            "cur_page_label": cur_page_label,
            "current_page": page
        }
    
        path = os.path.join(os.path.dirname(__file__), '../templates/team_list.html')
        return template.render(path, template_values)
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:34,代码来源:team_controller.py

示例3: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
 def get(self):
     team_keys = Team.query().fetch(keys_only=True)
     for team_key in team_keys:
         taskqueue.add(
             queue_name='search-index-update',
             url='/tasks/do/update_team_search_index/' + team_key.id(),
             method='GET')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:9,代码来源:admin_cron_controller.py

示例4: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        team_keys_future = Team.query().order(Team.team_number).fetch_async(keys_only=True)
        social_media_keys_future = Media.query(Media.year == None).fetch_async(keys_only=True)

        team_futures = ndb.get_multi_async(team_keys_future.get_result())
        social_futures = ndb.get_multi_async(social_media_keys_future.get_result())

        socials_by_team = defaultdict(dict)
        for social_future in social_futures:
            social = social_future.get_result()
            for reference in social.references:
                socials_by_team[reference.id()][social.media_type_enum] = social

        if team_futures:
            with cloudstorage.open(self.TEAMS_FILENAME_PATTERN, 'w') as teams_file:
                writer = csv.writer(teams_file, delimiter=',')
                for team_future in team_futures:
                    team = team_future.get_result()
                    team_row = [team.key.id(), team.nickname, team.name, team.city, team.state_prov, team.country, team.website, team.rookie_year]
                    for social_type in MediaType.social_types:
                        social = socials_by_team[team.key.id()].get(social_type, None)
                        team_row.append(social.social_profile_url if social is not None else None)
                    self._writerow_unicode(writer, team_row)

        self.response.out.write("Done backing up teams!")
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:27,代码来源:backup_controller.py

示例5: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        self._validate_tba_app_id()
        memcache_key = "csv_teams_all"
        output = memcache.get(memcache_key)

        if output is None:
            team_keys = Team.query().order(Team.team_number).fetch(10000, keys_only=True)
            team_futures = ndb.get_multi_async(team_keys)

            sio = StringIO.StringIO()
            writer = csv.writer(sio, delimiter=',')
            writer.writerow(['team_number','name','nickname','location','website'])

            for team_future in team_futures:
                team = team_future.get_result()
                row = [team.team_number, team.name, team.nickname, team.location, team.website]
                row_utf8 = [unicode(e).encode('utf-8') for e in row]
                writer.writerow(row_utf8)

            output = sio.getvalue()

            if tba_config.CONFIG["memcache"]:
                memcache.set(memcache_key, output, 86400)

        self.response.headers["content-type"] = "text/csv"
        self.response.out.write(output)

        self._track_call_defer('teams/list')
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:30,代码来源:api_controller.py

示例6: _render

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def _render(self, page_num):
        page_num = int(page_num)
        start = self.PAGE_SIZE * page_num
        end = start + self.PAGE_SIZE

        team_keys = Team.query(Team.team_number >= start, Team.team_number < end).fetch(None, keys_only=True)
        team_futures = ndb.get_multi_async(team_keys)
        team_list = [ModelToDict.teamConverter(team_future.get_result()) for team_future in team_futures]
        return json.dumps(team_list, ensure_ascii=True)
开发者ID:Captain-Dude,项目名称:the-blue-alliance,代码行数:11,代码来源:api_team_controller.py

示例7: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        self._require_admin()

        teams = Team.query().order(Team.team_number)

        self.template_values.update({"teams": teams})

        path = os.path.join(os.path.dirname(__file__), "../../templates/admin/team_list.html")
        self.response.out.write(template.render(path, self.template_values))
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:11,代码来源:admin_team_controller.py

示例8: createTeamMediaSuggestion

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def createTeamMediaSuggestion(self):
        user_bundle = UserBundle()
        team = Team.query().fetch(1)[0]

        SuggestionCreator.createTeamMediaSuggestion(
            author_account_key=user_bundle.account.key,
            media_url=self.YOUTUBE_URL,
            team_key=team.key_name,
            year_str="2016")
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:11,代码来源:suggestion_test_creator.py

示例9: createEventTeams

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def createEventTeams(self, event):
        teams = Team.query().order(Team.team_number).fetch(60)

        event_teams = [EventTeam(
            id = event.key.id() + "_" + team.key.id(),
            event = event.key,
            team = team.key,
            year = event.year)
            for team in teams]
        return EventTeamManipulator.createOrUpdate(event_teams)
开发者ID:lyncas,项目名称:the-blue-alliance,代码行数:12,代码来源:event_team_test_creator.py

示例10: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        team_keys = Team.query().order(Team.team_number).fetch(None, keys_only=True)
        team_futures = ndb.get_multi_async(team_keys)

        if team_futures:
            with cloudstorage.open(self.TEAMS_FILENAME_PATTERN, 'w') as teams_file:
                writer = csv.writer(teams_file, delimiter=',')
                for team_future in team_futures:
                    team = team_future.get_result()
                    self._writerow_unicode(writer, [team.key.id(), team.nickname, team.name, team.city, team.state_prov, team.country, team.website, team.rookie_year])

        self.response.out.write("Done backing up teams!")
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:14,代码来源:backup_controller.py

示例11: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        now_epoch = time.mktime(datetime.datetime.now().timetuple())
        bucket_num = int((now_epoch / (60 * 60 * 24)) % self.PERIOD)

        highest_team_key = Team.query().order(-Team.team_number).fetch(1, keys_only=True)[0]
        highest_team_num = int(highest_team_key.id()[3:])
        bucket_size = int(highest_team_num / (self.PERIOD)) + 1

        min_team = bucket_num * bucket_size
        max_team = min_team + bucket_size
        team_keys = Team.query(Team.team_number >= min_team, Team.team_number < max_team).fetch(1000, keys_only=True)

        teams = ndb.get_multi(team_keys)
        for team in teams:
            taskqueue.add(
                queue_name='usfirst',
                url='/tasks/get/usfirst_team_details/' + team.key_name,
                method='GET')

        # FIXME omg we're just writing out? -fangeugene 2013 Nov 6
        self.response.out.write("Bucket number {} out of {}<br>".format(bucket_num, self.PERIOD))
        self.response.out.write("{} team gets have been enqueued in the interval [{}, {}).".format(len(teams), min_team, max_team))
开发者ID:linuxuser0,项目名称:the-blue-alliance,代码行数:24,代码来源:datafeed_controller.py

示例12: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
 def get(self):
     offset = int(self.request.get("offset", 0))
     
     teams = Team.query().fetch(1000, offset=int(offset))
     for team in teams:
         taskqueue.add(
             queue_name='usfirst',
             url='/tasks/get/usfirst_team_details/' + team.key_name,
             method='GET')
     
     # FIXME omg we're just writing out? -gregmarra 2012 Aug 26
     self.response.out.write("%s team gets have been enqueued offset from %s.<br />" %(len(teams), offset))
     self.response.out.write("Reload with ?offset=%s to enqueue more." % (offset + len(teams)))
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:15,代码来源:datafeed_controller.py

示例13: _render

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def _render(self):
        events = Event.query().order(-Event.year).order(Event.name)       
        teams = Team.query().order(Team.team_number)

        results = []
        for event in events:
            results.append({'id': event.key_name, 'name': '%s %s [%s]' % (event.year, event.name, event.event_short.upper())})
        for team in teams:
            if not team.nickname:
                nickname = "Team %s" % team.team_number
            else:
                nickname = team.nickname
            results.append({'id': team.team_number, 'name': '%s | %s' % (team.team_number, nickname)})

        return json.dumps(results)
开发者ID:pyprogrammer,项目名称:the-blue-alliance,代码行数:17,代码来源:ajax_controller.py

示例14: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        memcache_key = "csv_teams_all"
        output = memcache.get(memcache_key)
    
        if output is None:
            teams = Team.query().order(Team.team_number).fetch(10000)        

            template_values = {
                "teams": teams
            }
        
            path = os.path.join(os.path.dirname(__file__), '../templates/api/csv_teams_all.csv')
            output = template.render(path, template_values)
            if tba_config.CONFIG["memcache"]: memcache.set(memcache_key, output, 86400)
        
        self.response.out.write(output)
开发者ID:dweitz,项目名称:the-blue-alliance,代码行数:18,代码来源:api_controller.py

示例15: get

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import query [as 别名]
    def get(self):
        self._validate_tba_app_id()
        memcache_key = "csv_teams_all"
        output = memcache.get(memcache_key)

        if output is None:
            team_keys = Team.query().order(Team.team_number).fetch(10000, keys_only=True)
            teams = ndb.get_multi(team_keys)

            template_values = {
                "teams": teams
            }

            path = os.path.join(os.path.dirname(__file__), '../templates/api/csv_teams_all.csv')
            output = template.render(path, template_values)
            if tba_config.CONFIG["memcache"]:
                memcache.set(memcache_key, output, 86400)

        self.response.headers["content-type"] = "text/csv"
        self.response.out.write(output)

        self._track_call_defer('teams/list')
开发者ID:lemiant,项目名称:the-blue-alliance,代码行数:24,代码来源:api_controller.py


注:本文中的models.team.Team.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。