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


Python insight.Insight类代码示例

本文整理汇总了Python中models.insight.Insight的典型用法代码示例。如果您正苦于以下问题:Python Insight类的具体用法?Python Insight怎么用?Python Insight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doOverallAwardInsights

    def doOverallAwardInsights(self):
        """
        Calculate award insights across all years. Returns a list of Insights.
        """
        insights = []

        year_regional_winners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.REGIONAL_DISTRICT_WINNERS], Insight.year != 0).fetch(1000)
        regional_winners = defaultdict(int)
        for insight in year_regional_winners:
            for number, team_list in insight.data:
                for team in team_list:
                    regional_winners[team] += number

        year_blue_banners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.BLUE_BANNERS], Insight.year != 0).fetch(1000)
        blue_banners = defaultdict(int)
        for insight in year_blue_banners:
            for number, team_list in insight.data:
                for team in team_list:
                    blue_banners[team] += number

        year_rca_winners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.RCA_WINNERS], Insight.year != 0).fetch(1000)
        rca_winners = defaultdict(int)
        for insight in year_rca_winners:
            for team in insight.data:
                rca_winners[team] += 1

        year_world_champions = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.WORLD_CHAMPIONS], Insight.year != 0).fetch(1000)
        world_champions = defaultdict(int)
        for insight in year_world_champions:
            for team in insight.data:
                world_champions[team] += 1

        # Sorting
        regional_winners = self._sortTeamWinsDict(regional_winners)
        blue_banners = self._sortTeamWinsDict(blue_banners)
        rca_winners = self._sortTeamWinsDict(rca_winners)
        world_champions = self._sortTeamWinsDict(world_champions)

        # Creating Insights
        if regional_winners:
            insights.append(self._createInsight(regional_winners, Insight.INSIGHT_NAMES[Insight.REGIONAL_DISTRICT_WINNERS], 0))

        if blue_banners:
            insights.append(self._createInsight(blue_banners, Insight.INSIGHT_NAMES[Insight.BLUE_BANNERS], 0))

        if rca_winners:
            insights.append(self._createInsight(rca_winners, Insight.INSIGHT_NAMES[Insight.RCA_WINNERS], 0))

        if world_champions:
            insights.append(self._createInsight(world_champions, Insight.INSIGHT_NAMES[Insight.WORLD_CHAMPIONS], 0))

        return insights
开发者ID:Captain-Dude,项目名称:the-blue-alliance,代码行数:52,代码来源:insights_helper.py

示例2: _render

 def _render(self):
     template_values = {
         'valid_years': VALID_YEARS,
     }
     
     insight_futures = [Insight.get_by_id_async(Insight.renderKeyName(0, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()]
     for insight_future in insight_futures:
         insight = insight_future.get_result()
         if insight:
             template_values[insight.name] = insight
                     
     path = os.path.join(os.path.dirname(__file__), '../templates/insights.html')
     return template.render(path, template_values)
开发者ID:germy,项目名称:the-blue-alliance,代码行数:13,代码来源:insights_controller.py

示例3: _createInsight

 def _createInsight(self, data, name, year):
     """
     Create Insight object given data, name, and year
     """
     return Insight(id=Insight.renderKeyName(year, name),
                    name=name,
                    year=year,
                    data_json=json.dumps(data))
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:8,代码来源:insights_helper.py

示例4: _render

    def _render(self):
        self.template_values.update({
            'valid_years': VALID_YEARS,
        })

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(0, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                self.template_values[insight.name] = insight

        return jinja2_engine.render('insights.html', self.template_values)
开发者ID:Nascar,项目名称:the-blue-alliance,代码行数:11,代码来源:insights_controller.py

示例5: _render

    def _render(self):
        self.template_values.update({
            'valid_years': VALID_YEARS,
        })

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(0, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                self.template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/insights.html')
        return template.render(path, self.template_values)
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:12,代码来源:insights_controller.py

示例6: _render

    def _render(self, *args, **kw):
        week_events = EventHelper.getWeekEvents()
        template_values = {
            "events": week_events,
        }

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(2013, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/index_insights.html')
        return template.render(path, template_values)
开发者ID:nightpool,项目名称:the-blue-alliance,代码行数:13,代码来源:main_controller.py

示例7: _render

    def _render(self, year):
        template_values = {
            'valid_years': VALID_YEARS,
            'selected_year': year,
        }

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(year, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/insights_details.html')
        return template.render(path, template_values)
开发者ID:chrismarra,项目名称:the-blue-alliance,代码行数:13,代码来源:insights_controller.py

示例8: _render

    def _render(self, *args, **kw):
        year = datetime.datetime.now().year
        event_keys = Event.query(Event.year == year, Event.event_type_enum.IN(EventType.CMP_EVENT_TYPES)).fetch(100, keys_only=True)
        events = [event_key.get() for event_key in event_keys]
        template_values = {
            "events": events,
        }

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(year, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/index_champs.html')
        return template.render(path, template_values)
开发者ID:lemiant,项目名称:the-blue-alliance,代码行数:15,代码来源:main_controller.py

示例9: _render

    def _render(self, *args, **kw):
        week_events = EventHelper.getWeekEvents()
        year = datetime.datetime.now().year
        self.template_values.update({
            "events": week_events,
            "year": year,
        })

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(year, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                self.template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/index_insights.html')
        return template.render(path, self.template_values)
开发者ID:cmlicata,项目名称:the-blue-alliance,代码行数:15,代码来源:main_controller.py

示例10: doOverallMatchInsights

    def doOverallMatchInsights(self):
        """
        Calculate match insights across all years. Returns a list of Insights.
        """
        insights = []

        year_num_matches = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.NUM_MATCHES], Insight.year != 0).fetch(1000)
        num_matches = []
        for insight in year_num_matches:
            num_matches.append((insight.year, insight.data))

        # Creating Insights
        if num_matches:
            insights.append(self._createInsight(num_matches, Insight.INSIGHT_NAMES[Insight.NUM_MATCHES], 0))

        return insights
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:16,代码来源:insights_helper.py

示例11: _render

    def _render(self, *args, **kw):
        week_events = EventHelper.getWeekEvents()
        year = datetime.datetime.now().year
        special_webcasts = FirebasePusher.get_special_webcasts()
        self.template_values.update({
            "events": week_events,
            "year": year,
            "any_webcast_online": any(w.get('status') == 'online' for w in special_webcasts),
            "special_webcasts": special_webcasts,
        })

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(year, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        for insight in insights:
            if insight:
                self.template_values[insight.name] = insight

        path = os.path.join(os.path.dirname(__file__), '../templates/index_insights.html')
        return template.render(path, self.template_values)
开发者ID:legoktm,项目名称:the-blue-alliance,代码行数:18,代码来源:main_controller.py

示例12: _render

    def _render(self):
        self.template_values.update({
            'valid_years': VALID_YEARS,
        })

        insights = ndb.get_multi([ndb.Key(Insight, Insight.renderKeyName(0, insight_name)) for insight_name in Insight.INSIGHT_NAMES.values()])
        last_updated = None
        for insight in insights:
            if insight:
                self.template_values[insight.name] = insight
                if last_updated is None:
                    last_updated = insight.updated
                else:
                    last_updated = max(last_updated, insight.updated)

        self.template_values['last_updated'] = last_updated

        return jinja2_engine.render('insights.html', self.template_values)
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:18,代码来源:insights_controller.py

示例13: doOverallAwardInsights

    def doOverallAwardInsights(self):
        """
        Calculate award insights across all years. Returns a list of Insights.
        """
        insights = []

        year_regional_winners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.REGIONAL_DISTRICT_WINNERS], Insight.year != 0).fetch(1000)
        regional_winners = defaultdict(int)
        for insight in year_regional_winners:
            for number, team_list in insight.data:
                for team in team_list:
                    regional_winners[team] += number

        year_blue_banners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.BLUE_BANNERS], Insight.year != 0).fetch(1000)
        blue_banners = defaultdict(int)
        for insight in year_blue_banners:
            for number, team_list in insight.data:
                for team in team_list:
                    blue_banners[team] += number

        year_rca_winners = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.RCA_WINNERS], Insight.year != 0).fetch(1000)
        rca_winners = defaultdict(int)
        for insight in year_rca_winners:
            for team in insight.data:
                rca_winners[team] += 1

        year_world_champions = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.WORLD_CHAMPIONS], Insight.year != 0).fetch(1000)
        world_champions = defaultdict(int)
        for insight in year_world_champions:
            for team in insight.data:
                world_champions[team] += 1

        year_successful_elim_teamups = Insight.query(Insight.name == Insight.INSIGHT_NAMES[Insight.SUCCESSFUL_ELIM_TEAMUPS], Insight.year != 0).fetch(1000)
        successful_elim_teamups = defaultdict(int)
        for insight in year_successful_elim_teamups:
            for teams in insight.data:
                for pairs in itertools.combinations(teams, 2):
                    successful_elim_teamups[tuple(sorted(pairs))] += 1
        successful_elim_teamups_sorted = defaultdict(list)
        for teams, num_wins in successful_elim_teamups.items():
            sorted_teams = sorted(teams, key=lambda team_key: int(team_key[3:]))
            successful_elim_teamups_sorted[num_wins].append(sorted_teams)
        successful_elim_teamups_sorted = sorted(successful_elim_teamups_sorted.items(), key=lambda x: -x[0])

        # Sorting
        regional_winners = self._sortTeamWinsDict(regional_winners)
        blue_banners = self._sortTeamWinsDict(blue_banners)
        rca_winners = self._sortTeamWinsDict(rca_winners)
        world_champions = self._sortTeamWinsDict(world_champions)

        # Creating Insights
        if regional_winners:
            insights.append(self._createInsight(regional_winners, Insight.INSIGHT_NAMES[Insight.REGIONAL_DISTRICT_WINNERS], 0))

        if blue_banners:
            insights.append(self._createInsight(blue_banners, Insight.INSIGHT_NAMES[Insight.BLUE_BANNERS], 0))

        if rca_winners:
            insights.append(self._createInsight(rca_winners, Insight.INSIGHT_NAMES[Insight.RCA_WINNERS], 0))

        if world_champions:
            insights.append(self._createInsight(world_champions, Insight.INSIGHT_NAMES[Insight.WORLD_CHAMPIONS], 0))

        if year_successful_elim_teamups:
            insights.append(self._createInsight(successful_elim_teamups_sorted, Insight.INSIGHT_NAMES[Insight.SUCCESSFUL_ELIM_TEAMUPS], 0))

        return insights
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:67,代码来源:insights_helper.py


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