VirtualBox

Changeset 65500 in vbox for trunk/src


Ignore:
Timestamp:
Jan 28, 2017 10:16:08 PM (8 years ago)
Author:
vboxsync
Message:

wuireport.py: try decimal point on success graph when going below 10%.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuireport.py

    r65499 r65500  
    117117        return (sTitle, sReport);
    118118
     119    @staticmethod
     120    def fmtPct(cHits, cTotal):
     121        """
     122        Formats a percent number.
     123        Returns a string.
     124        """
     125        uPct = cHits * 100 / cTotal;
     126        if uPct >= 10:
     127            return '%s%%' % (uPct,);
     128        return '%.1f%%' % (cHits * 100.0 / cTotal,);
     129
     130    @staticmethod
     131    def fmtPctWithTotal(cHits, cTotal):
     132        """
     133        Formats a percent number with total in parentheses.
     134        Returns a string.
     135        """
     136        return '%s (%s)' % (WuiReportBase.fmtPct(cHits, cTotal), cTotal);
     137
     138    @staticmethod
     139    def fmtPctWithHitsAndTotal(cHits, cTotal):
     140        """
     141        Formats a percent number with total in parentheses.
     142        Returns a string.
     143        """
     144        return '%s (%s/%s)' % (WuiReportBase.fmtPct(cHits, cTotal), cHits, cTotal);
     145
     146
    119147
    120148class WuiReportSuccessRate(WuiReportBase):
     
    138166            sPeriod   = self._oModel.getPeriodDesc(i);
    139167            if cTotal > 0:
    140                 iPctSuccess = dStatuses[ReportModelBase.ksTestStatus_Success] * 100 / cTotal;
    141                 iPctSkipped = dStatuses[ReportModelBase.ksTestStatus_Skipped] * 100 / cTotal;
    142                 iPctFailure = dStatuses[ReportModelBase.ksTestStatus_Failure] * 100 / cTotal;
    143                 oTable.addRow(sPeriod, [ iPctSuccess, iPctSkipped, iPctFailure ],
    144                               [ '%s%% (%d)' % (iPctSuccess, dStatuses[ReportModelBase.ksTestStatus_Success]),
    145                                 '%s%% (%d)' % (iPctSkipped, dStatuses[ReportModelBase.ksTestStatus_Skipped]),
    146                                 '%s%% (%d)' % (iPctFailure, dStatuses[ReportModelBase.ksTestStatus_Failure]), ]);
     168                oTable.addRow(sPeriod,
     169                              [ dStatuses[ReportModelBase.ksTestStatus_Success] * 100 / cTotal,
     170                                dStatuses[ReportModelBase.ksTestStatus_Skipped] * 100 / cTotal,
     171                                dStatuses[ReportModelBase.ksTestStatus_Failure] * 100 / cTotal, ],
     172                              [ self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Success], cTotal),
     173                                self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Skipped], cTotal),
     174                                self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Failure], cTotal), ]);
    147175            else:
    148176                oTable.addRow(sPeriod, [ 0, 0, 0 ], [ '0%', '0%', '0%' ]);
     
    380408                        oRow = oPeriod.dRowsById.get(idKey, None);
    381409                        if oRow is not None:
    382                             uPct = oRow.cHits * 100 / oRow.cTotal;
    383                             aiValues.append(uPct);
    384                             if uPct >= 10:
    385                                 asValues.append('%u%% (%u/%u)' % (uPct, oRow.cHits, oRow.cTotal));
    386                             else:
    387                                 asValues.append('%.1f%% (%u/%u)' % (oRow.cHits * 100.0 / oRow.cTotal, oRow.cHits, oRow.cTotal));
     410                            aiValues.append(oRow.cHits * 100 / oRow.cTotal);
     411                            asValues.append(self.fmtPctWithHitsAndTotal(oRow.cHits, oRow.cTotal));
    388412                        else:
    389413                            aiValues.append(0);
     
    398422                        uPct = oSet.dcHitsPerId[idKey] * 100 / oSet.dcTotalPerId[idKey];
    399423                        aiValues.append(uPct);
    400                         if uPct >= 10:
    401                             asValues.append('%u%% (%u/%u)' % (uPct, oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey]));
    402                         else:
    403                             asValues.append('%.1f%% (%u/%u)' % ( oSet.dcHitsPerId[idKey] * 100.0 / oSet.dcTotalPerId[idKey],
    404                                                                  oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey],));
     424                        asValues.append(self.fmtPctWithHitsAndTotal(oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey]));
    405425                    oTable.addRow('Totals', aiValues, asValues);
    406426
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette