Ejemplo n.º 1
0
 def get_most_used_room_week(self, query, week_start,
                             week_end):  # noqa: E501
     """ Get analytics for most used room per week
      :params
         - calendar_id
         - week_start, week_end(Time range)
     """
     week_start = CommonAnalytics.convert_date(self, week_start)
     week_end = CommonAnalytics.convert_date(self, week_end)
     rooms_available = CommonAnalytics.get_calendar_id_name(self, query)
     res = []
     number_of_most_events = 0
     for room in rooms_available:
         calendar_events = CommonAnalytics.get_all_events_in_a_room(
             self, room['calendar_id'], week_start, week_end)
         output = []
         if not calendar_events:
             output.append({'RoomName': room['name'], 'has_events': False})
             number_of_most_events = 0
         else:
             for event in calendar_events:
                 event_details = CommonAnalytics.get_event_details(
                     self, event, room['calendar_id'])
                 output.append(event_details)
             if len(output) > number_of_most_events:
                 number_of_most_events = len(output)
         res.append(output)
     analytics = CommonAnalytics.get_room_statistics(
         self, number_of_most_events, res)
     return analytics
Ejemplo n.º 2
0
 def get_meetings_per_room(self, query, timeMin, timeMax):
     day_start = CommonAnalytics.convert_date(self, timeMin)
     day_end = CommonAnalytics.convert_date(self, timeMax)
     rooms_available = CommonAnalytics.get_calendar_id_name(self, query)
     res = []
     for room in rooms_available:
         calendar_events = CommonAnalytics.get_all_events_in_a_room(
             self, room['calendar_id'], day_start, day_end)
         room_details = RoomStatistics(
             room_name=room["name"],
             count=len(calendar_events))  # noqa: E501
         res.append(room_details)
     return res
Ejemplo n.º 3
0
    def get_least_used_room_week(self, query, week_start,
                                 week_end):  # noqa: E501
        """ Get analytics for least used room per week
         :params
            - calendar_id
            - week_start, week_end(Time range)
        """
        week_start = CommonAnalytics.convert_date(self, week_start)
        week_end = CommonAnalytics.convert_date(self, week_end)

        rooms_available = CommonAnalytics.get_calendar_id_name(self, query)
        return RoomAnalytics.get_least_used_rooms(self, rooms_available,
                                                  week_start,
                                                  week_end)  # noqa: E501
Ejemplo n.º 4
0
    def get_monthly_rooms_events(self, query, month, year):
        """ Get event stats for all rooms in a specified month
         :params
            - month, year
        """
        date = month + ' 1 ' + str(year)
        startdate = CommonAnalytics.convert_date(self, date)
        date_after_month = (
            datetime.strptime(date, '%b %d %Y') +
            relativedelta(months=1)).isoformat() + 'Z'  # noqa: E501

        rooms_available = CommonAnalytics.get_calendar_id_name(self, query)
        room_events_count = []
        events_in_all_rooms = []
        for room in rooms_available:
            calendar_events = CommonAnalytics.get_all_events_in_a_room(
                self, room['calendar_id'], startdate, date_after_month)
            output = []
            if not calendar_events:
                output.append({'RoomName': room['name'], 'has_events': False})
                room_with_no_events = 0
                room_events_count.append(room_with_no_events)

            else:
                for event in calendar_events:
                    if event.get('attendees'):
                        event_details = CommonAnalytics.get_event_details(
                            self, event, room['calendar_id'])
                        output.append(event_details)
                room_events_count.append(len(output))
            events_in_all_rooms.append(output)
        return dict(events_in_all_rooms=events_in_all_rooms,
                    room_events_count=room_events_count)
Ejemplo n.º 5
0
 def get_weekly_meetings_details(self, query, week_start,
                                 week_end):  # noqa: E501
     """
     Get weekly meeting durations details
     """
     week_start = CommonAnalytics.convert_date(self, week_start)
     week_end, day_after = CommonAnalytics.get_start_end_day_dates(
         self, week_end)  # noqa: E501
     weekly_analytics = RoomAnalytics.meetings_duration_statistics(
         self, query, week_start, day_after)  # noqa: E501
     return weekly_analytics