Beispiel #1
0
 def createExecSqlNodeReason(self, contributor, profile):
     """
     For the given contributor, return the top reasons why it's slow. A list of models.Reason
     object will be created, persisted to the database and returned.
     The result will be in the form of
     """
     reasons = []
     self.sqlOperatorReasons.setdefault(contributor.plan_node_name, [])
     for cause in self.sqlOperatorReasons[
             contributor.plan_node_name] + self.sqlOperatorReasons["ANY"]:
         evaluation = cause.evaluate(profile, contributor.plan_node_id)
         impact = evaluation["impact"]
         if isinstance(impact, float) and (impact).is_integer():
             evaluation["impact"] = int(impact)
         if (evaluation["impact"] > 0):
             fix = {}
             fix.update(cause.kwargs['fix'])
             if evaluation.get('data'):
                 fix['data'] = evaluation['data']
             reason = models.Reason(message=evaluation['message'],
                                    impact=evaluation['impact'],
                                    unit=cause.kwargs.get('unit_id', ''),
                                    fix=fix)
             reasons.append(reason)
     return sorted(reasons, key=lambda x: x.impact, reverse=True)
Beispiel #2
0
 def createExecNodeReason(self, contributor, profile):
     """
     For the given contributor, return the top reasons why it's slow. A list of models.Reason
     object will be created, persisted to the database and returned.
     The result will be in the form of
     """
     reasons = []
     self.sqlOperatorReasons.setdefault(contributor.type, [])
     for cause in self.sqlOperatorReasons[contributor.type]:
         evaluation = cause.evaluate(profile, contributor.plan_node_id)
         impact = evaluation["impact"]
         if isinstance(impact, float) and (impact).is_integer():
             evaluation["impact"] = int(impact)
         if (evaluation["impact"] > 0):
             reason = models.Reason(message=evaluation['message'],
                                    impact=evaluation['impact'])
             reasons.append(reason)
     return sorted(reasons, key=lambda x: x.impact, reverse=True)