Esempio n. 1
0
    def addToResult(self, result):
        waitTime = int(total_seconds(self.waitEnd - self.waitStart))

        # default value is '-', displayed if no data for waitingTime were available from EventLogs
        if isinstance(result['avgWaitTime'], int):
            result['avgWaitTime'] = (result['avgWaitTime'] + waitTime) / 2
        else:
            result['avgWaitTime'] = waitTime

        # calculate 'queued' stat
        if waitTime >= WaitingTimeFilter.QUEUED_THRESHOLD:
            result['queued'] += 1
Esempio n. 2
0
    def render(cls, listOfObjects):
        dictStats = OrderedDict()
        
        listOfChats, listOfEvents = listOfObjects
        
        for chat in listOfChats:
            key = str(chat.id)
            
            # init new entry in dictStats, if necessary
            if key not in dictStats:
                dictStats[key] = cls._empty_dict_entry()
                
            clientParticipant = chat.getClient()
            staffParticipant = chat.getStaff()

            dictStats[key]['date'] = chat.start_time
            dictStats[key]['id'] = chat.id
            
            if chat.hasQuestionnaire():
                dictStats[key]['questionnairesSubmitted'] = 1
            
            # was client Participant blocked?
            if not clientParticipant is None and clientParticipant.blocked is True:
                dictStats[key]['blocked'] = 1

            # staff member and client assigned to this Conversation?
            if not staffParticipant is None and not clientParticipant is None:
                dictStats[key]['assigned'] = 1

            # did both Participants chat?
            if chat.hasInteraction():
                dictStats[key]['interaction'] = 1

            if not clientParticipant is None:
                dictStats[key]['clientIP'] = clientParticipant.ip_hash

            dictStats[key]['clientName'] = chat.client_name()
            dictStats[key]['staffName'] = chat.staff_name()
            dictStats[key]['subject'] = chat.subject

            # chatting time
            duration = chat.duration()
            if isinstance(duration, datetime.timedelta):
                dictStats[key]['avgChatTime'] = int(total_seconds(duration))


        # process EventLogs
        EventLogProcessor(listOfEvents, [WaitingTimeFlatFilter()]).run(dictStats)

        return dictStats
Esempio n. 3
0
    def extract_value(cls, obj, context=None):
        try:
            duration_minutes = total_seconds(obj.duration()) / 60.0

            if duration_minutes >= 0.0 and duration_minutes < 5.0:
                return _('0-5')
            elif duration_minutes >= 5.0 and duration_minutes < 10.0:
                return _('5-10')
            elif duration_minutes >= 10.0 and duration_minutes < 15.0:
                return _('10-15')
            elif duration_minutes >= 15.0 and duration_minutes < 25.0:
                return _('15-25')
            elif duration_minutes >= 25.0 and duration_minutes < 45.0:
                return _('25-45')
            elif duration_minutes >= 45.0:
                return _('45+')
            else:
                return Report.OTHER_COLUMN
        except:
            return Report.OTHER_COLUMN
Esempio n. 4
0
    def render(cls, listOfObjects):
        dictStats = OrderedDict()

        listOfChats, listOfEvents = listOfObjects

        for chat in listOfChats:
            # determine key under which to place `chat` in `dictStats`
            key = chat.hourAgg
            
            # init new entry in dictStats, if necessary
            if key not in dictStats:
                dictStats[key] = cls._empty_dict_entry()


            try:
                dictStats[key]['date'], dictStats[key]['hour'] = key.split(" ")
                
                dictStats[key]['date'] = formats.date_format(datetime.datetime.strptime(dictStats[key]['date'], '%Y-%m-%d').date(), 'SHORT_DATE_FORMAT')
                dictStats[key]['hour'] = int(dictStats[key]['hour'])
            except:
                pass

            
            clientParticipant = chat.getClient()
            staffParticipant = chat.getStaff()

            if not clientParticipant is None:
                # track unique IPs, unless there was no Participant in the Conversation
                if clientParticipant.ip_hash not in dictStats[key]['ipTable']:
                    dictStats[key]['ipTable'][clientParticipant.ip_hash] = 0

                # was client Participant blocked?
                if clientParticipant.blocked is True:
                    dictStats[key]['blocked'] += 1

            if chat.hasQuestionnaire():
                dictStats[key]['questionnairesSubmitted'] += 1

            # staff member and client assigned to this Conversation?
            if not staffParticipant is None and not clientParticipant is None:
                dictStats[key]['assigned'] += 1

            # did both Participants chat?
            if chat.hasInteraction():
                dictStats[key]['interaction'] += 1

            # chatting time
            duration = chat.duration()
            if isinstance(duration, datetime.timedelta):
                dictStats[key]['avgChatTime'] += int(total_seconds(duration))
                dictStats[key]['numChatTime'] += 1

            # count this Chat object
            dictStats[key]['totalCount'] += 1


        # post-processing
        for key in dictStats.iterkeys():
            # count unique IPs
            dictStats[key]['uniqueIPs'] = len(dictStats[key]['ipTable'].keys())
            del dictStats[key]['ipTable']

            # calc avg chat time
            try:
                dictStats[key]['avgChatTime'] = dictStats[key]['avgChatTime'] / dictStats[key]['numChatTime']
            except ZeroDivisionError:
                dictStats[key]['avgChatTime'] = "-"
            del dictStats[key]['numChatTime']


        # process EventLogs
        EventLogProcessor(listOfEvents, [WaitingTimeFilter()]).run(dictStats)

        return dictStats