Пример #1
0
    def _getBurndownImgStr(self, milestone, date):
        """ get burndown image string
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # prepare chart data
        # init chart data
        chartData = {"due":{},
                     "done":{},
                    }

        # get history data from db
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)
        if not startdate:
            # no ticket in this milestone
            # skip
            return ""

        dateMin = int(startdate) / SECPERDAY + 1
        dateMax = int(enddate) / SECPERDAY + 1
        if dateMax > date:
            dateMax = date


        max_history_date = MMV_List.getMaxHistoryDate(self.env, milestone)
        # add history
        for add_date in range(dateMin, dateMax + 1):
            if add_date < max_history_date - 2:
                # don't update stable history
                continue
            MMV_List(self.env).addHistory(self.env, add_date, milestone)

        # get due
        dueData = MMV_List.getDue(self.env, dateMin, dateMax, milestone)
        for date, dueDays in dueData:
            dateString = formatDateCompact(date * SECPERDAY)
            chartData["due"][dateString] = dueDays

        # get done
        doneData = MMV_List.getDue(self.env, dateMin, dateMax, milestone)
        for date, doneDays in doneData:
            dateString = formatDateCompact(date * SECPERDAY)
            chartData["done"][dateString] = doneDays

        # genearte chart
        subMilestone = stripMilestoneName(milestone)
        returnStr = self._genLineChart(chartData, subMilestone, subMilestone)

        return returnStr
Пример #2
0
    def _getDateList(self, milestone):
        """ get all dates of a milestone
        """
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)

        

        dateMin = int(startdate) / SECPERDAY
        dateMax = int(enddate) / SECPERDAY

        dateList = range(dateMax, dateMin - 1, -1)

        return dateList
Пример #3
0
    def _getMemberImgStr(self, milestone, member):
        """ get one member image string
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # prepare chart data
        # init chart data
        chartData = {"due":{},
                     "done":{},
                    }


        # get history data from db
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)

        dateMin = int(startdate) / SECPERDAY
        dateMax = int(enddate) / SECPERDAY

        # due
        for aDay in range(dateMin, dateMax + 1):
            dateString = formatDateCompact(aDay * SECPERDAY)
            dateEndTime = (aDay + 1) * SECPERDAY

            sqlString = """
                SELECT tc.ticket, tc.name, tc.value 
                FROM ticket_custom tc, ticket t 
                WHERE tc.ticket = t.id 
                AND tc.name = '%(duetime)s' 
                AND t.id IN (
                    SELECT ta.id FROM 
                    (SELECT id
                     FROM ticket
                     WHERE time < %(dateEndTime)s  AND owner = '%(member)s' ) AS ta 
                     LEFT JOIN
                    (SELECT DISTINCT B.ticket AS ticket, B.time AS time, A.newvalue AS newvalue
                     FROM ticket_change A,
                     (SELECT  ticket, max(time) AS time
                     FROM ticket_change 
                     WHERE field = 'status' 
                     AND time < %(dateEndTime)s
                     GROUP BY ticket 
                     ORDER BY ticket) AS B
                     WHERE A.ticket = B.ticket 
                     AND A.time = B.time
                     AND A.field = 'status'
                     AND newvalue IN ('closed','reopened') ) AS tb 
                     ON ta.id = tb.ticket
                     WHERE tb.newvalue != 'closed' OR tb.newvalue IS NULL
                     )  
                AND t.milestone = '%(milestone)s';
            """ % {'dateEndTime':dateEndTime, 
                    'milestone':milestone, 
                    'member':member, 
                    'duetime':_getDueField(self.config), }

            cursor.execute(sqlString)
            rows = cursor.fetchall()

            # calculate total due days
            dueDays = 0
            for row in rows:
                duetime = row[2]
                dueDays += dueday(duetime)

            chartData["due"][dateString] = dueDays


        # done
        for aDay in range(dateMin, dateMax + 1):
            dateString = formatDateCompact(aDay * SECPERDAY)
            dateEndTime = (aDay + 1) * SECPERDAY

            sqlString = """
                SELECT tc.ticket, tc.name, tc.value 
                FROM ticket_custom tc, ticket t 
                WHERE tc.ticket = t.id 
                AND tc.name = '%(duetime)s' 
                AND t.id IN (
                    SELECT ta.id FROM 
                    (SELECT id
                     FROM ticket
                     WHERE time < %(dateEndTime)s  AND owner = '%(member)s' ) AS ta 
                     LEFT JOIN
                    (SELECT DISTINCT B.ticket AS ticket, B.time AS time, A.newvalue AS newvalue
                     FROM ticket_change A,
                     (SELECT  ticket, max(time) AS time
                     FROM ticket_change 
                     WHERE field = 'status' 
                     AND time < %(dateEndTime)s
                     GROUP BY ticket 
                     ORDER BY ticket) AS B
                     WHERE A.ticket = B.ticket 
                     AND A.time = B.time
                     AND A.field = 'status'
                     AND newvalue IN ('closed','reopened') ) AS tb 
                     ON ta.id = tb.ticket
                     WHERE tb.newvalue = 'closed'
                     )  
                AND t.milestone = '%(milestone)s';
            """ % {'dateEndTime':dateEndTime, 
                    'milestone':milestone, 
                    'member':member, 
                    'duetime':_getDueField(self.config), }

            cursor.execute(sqlString)
            rows = cursor.fetchall()

            # calculate total due days
            dueDays = 0
            for row in rows:
                duetime = row[2]
                dueDays += dueday(duetime)

            chartData["done"][dateString] = dueDays


        print chartData

        # genearte chart
        subMilestone = stripMilestoneName(milestone)
        returnStr = self._genLineChart(chartData, subMilestone, member)

        return returnStr