Пример #1
0
class StatusBubble(webapp.RequestHandler):
    _queues_to_display = [queue for queue in Queue.all() if queue.is_ews()]

    def _build_bubble(self, queue, attachment):
        queue_status = attachment.status_for_queue(queue)
        bubble = {
            "name":
            queue.short_name().lower(),
            "attachment_id":
            attachment.id,
            "queue_position":
            attachment.position_in_queue(queue),
            "state":
            attachment.state_from_queue_status(queue_status)
            if queue_status else "none",
            "status":
            queue_status,
        }
        return bubble

    def get(self, attachment_id):
        attachment = Attachment(int(attachment_id))
        bubbles = [
            self._build_bubble(queue, attachment)
            for queue in self._queues_to_display
        ]
        template_values = {
            "bubbles": bubbles,
        }
        self.response.out.write(
            template.render("templates/statusbubble.html", template_values))
Пример #2
0
class Dashboard(webapp.RequestHandler):
    # We may want to sort these?
    _ordered_queues = Queue.all()
    _header_names = [queue.short_name() for queue in _ordered_queues]

    def _build_bubble(self, attachment, queue):
        queue_status = attachment.status_for_queue(queue)
        bubble = {
            "status_class": attachment.state_from_queue_status(queue_status) if queue_status else "none",
            "status_date": queue_status.date if queue_status else None,
        }
        return bubble

    def _build_row(self, attachment):
        row = {
            "bug_id": attachment.bug_id(),
            "attachment_id": attachment.id,
            "bubbles": [self._build_bubble(attachment, queue) for queue in self._ordered_queues],
        }
        return row

    def get(self):
        template_values = {
            "headers": self._header_names,
            "rows": [self._build_row(attachment) for attachment in Attachment.recent(limit=25)],
        }
        self.response.out.write(template.render("templates/dashboard.html", template_values))
Пример #3
0
    def get(self, queue_name):
        queue_name = queue_name.lower()
        if not Queue.queue_with_name(queue_name):
            self.error(404)
            return

        timestamp = self._get_timestamp()
        view_range = self._get_view_range()
        time_unit, time_unit_name = charts.get_time_unit(view_range)

        all_queue_names = map(Queue.name, Queue.all())

        template_values = {
            "all_queue_names": all_queue_names,
            "patch_data": self._get_patch_data(queue_name, timestamp,
                                               view_range),
            "queue_data": self._get_queue_data(queue_name, timestamp,
                                               view_range),
            "queue_name": queue_name,
            "seconds_ago_min": 0,
            "seconds_ago_max": view_range,
            "time_unit_name": time_unit_name,
            "time_unit": time_unit,
            "timestamp": timestamp,
            "view_range": view_range,
            "view_range_choices": charts.view_range_choices,
        }
        self.response.out.write(
            template.render("templates/queuecharts.html", template_values))
Пример #4
0
    def get(self, queue_name):
        queue_name = queue_name.lower()
        if not Queue.queue_with_name(queue_name):
            self.error(404)
            return

        timestamp = self._get_timestamp()
        view_range = self._get_view_range()
        time_unit, time_unit_name = charts.get_time_unit(view_range)

        all_queue_names = map(Queue.name, Queue.all())

        template_values = {
            "all_queue_names": all_queue_names,
            "patch_data": self._get_patch_data(queue_name, timestamp, view_range),
            "queue_data": self._get_queue_data(queue_name, timestamp, view_range),
            "queue_name": queue_name,
            "seconds_ago_min": 0,
            "seconds_ago_max": view_range,
            "time_unit_name": time_unit_name,
            "time_unit": time_unit,
            "timestamp": timestamp,
            "view_range": view_range,
            "view_range_choices": charts.view_range_choices,
        }
        self.response.out.write(template.render("templates/queuecharts.html", template_values))
Пример #5
0
 def _queue_from_request(self):
     queue_name = self.request.get("queue_name")
     queue = Queue.queue_with_name(queue_name)
     if not queue:
         self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
         return None
     return queue
Пример #6
0
 def _queue_from_request(self):
     queue_name = self.request.get("queue_name")
     queue = Queue.queue_with_name(queue_name)
     if not queue:
         self.response.out.write("\"%s\" is not in queues %s" %
                                 (queue_name, Queue.all()))
         return None
     return queue
Пример #7
0
    def _work_items_from_request(self):
        queue_name = self.request.get("queue_name")
        queue = Queue.queue_with_name(queue_name)
        if not queue:
            self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
            return None

        items_string = self.request.get("work_items")
        work_items = queue.work_items()
        work_items.item_ids = self._parse_work_items_string(items_string)
        work_items.date = datetime.now()
        return work_items
Пример #8
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._have_status_for(attachment, queue):
                continue
            bubbles.append(self._build_bubble(queue, attachment))
            # If even one ews has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        return (bubbles, show_submit_to_ews)
Пример #9
0
    def _work_items_from_request(self):
        queue_name = self.request.get("queue_name")
        queue = Queue.queue_with_name(queue_name)
        if not queue:
            self.response.out.write("\"%s\" is not in queues %s" %
                                    (queue_name, Queue.all()))
            return None

        items_string = self.request.get("work_items")
        work_items = queue.work_items()
        work_items.item_ids = self._parse_work_items_string(items_string)
        work_items.date = datetime.now()
        return work_items
Пример #10
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._should_show_bubble_for(attachment, queue):
                continue
            queue_position = attachment.position_in_queue(queue)
            bubble = self._build_bubble(queue, attachment, queue_position)
            if bubble:
                bubbles.append(bubble)
            # If at least one EWS queue has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        return (bubbles, show_submit_to_ews)
Пример #11
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._have_status_for(attachment, queue):
                continue
            queue_position = attachment.position_in_queue(queue)
            if queue_position and queue_position >= 100:
                # This queue is so far behind it's not even worth showing.
                continue
            bubbles.append(self._build_bubble(queue, attachment, queue_position))
            # If even one ews has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        return (bubbles, show_submit_to_ews)
Пример #12
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._have_status_for(attachment, queue):
                continue
            queue_position = attachment.position_in_queue(queue)
            if queue_position and queue_position >= 100:
                # This queue is so far behind it's not even worth showing.
                continue
            bubbles.append(
                self._build_bubble(queue, attachment, queue_position))
            # If even one ews has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        return (bubbles, show_submit_to_ews)
Пример #13
0
    def _fetch_summary(self):
        summary = { "attachment_id" : self.id }

        first_status = QueueStatus.all().filter('active_patch_id =', self.id).get()
        if not first_status:
            # We don't have any record of this attachment.
            return summary
        summary["bug_id"] = first_status.active_bug_id

        for queue in Queue.all():
            summary[queue.name_with_underscores()] = None
            status = QueueStatus.all().filter('queue_name =', queue.name()).filter('active_patch_id =', self.id).order('-date').get()
            if status:
                # summary() is a horrible API and should be killed.
                summary[queue.name_with_underscores()] = {
                    "status": status,
                }
        return summary
Пример #14
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._should_show_bubble_for(attachment, queue):
                continue
            queue_position = attachment.position_in_queue(queue)
            bubble = self._build_bubble(queue, attachment, queue_position)
            if bubble:
                bubbles.append(bubble)
            # If at least one EWS queue has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        failed_to_apply = any(map(lambda bubble: "failed_to_apply" in bubble, bubbles))
        had_resultative_status_other_than_failure_to_apply = any(map(lambda bubble: bubble["had_resultative_status_other_than_failure_to_apply"], bubbles))

        return (bubbles, show_submit_to_ews, failed_to_apply and not had_resultative_status_other_than_failure_to_apply)
Пример #15
0
    def _build_bubbles_for_attachment(self, attachment):
        show_submit_to_ews = True
        bubbles = []
        for queue in Queue.all():
            if not self._should_show_bubble_for(attachment, queue):
                continue
            queue_position = attachment.position_in_queue(queue)
            bubble = self._build_bubble(queue, attachment, queue_position)
            if bubble:
                bubbles.append(bubble)
            # If at least one EWS queue has status, we don't show the submit-to-ews button.
            if queue.is_ews():
                show_submit_to_ews = False

        failed_to_apply = any(map(lambda bubble: "failed_to_apply" in bubble, bubbles))
        had_resultative_status_other_than_failure_to_apply = any(map(lambda bubble: bubble["had_resultative_status_other_than_failure_to_apply"], bubbles))

        return (bubbles, show_submit_to_ews, failed_to_apply and not had_resultative_status_other_than_failure_to_apply)
Пример #16
0
    def _fetch_summary(self):
        summary = { "attachment_id" : self.id }

        first_status = QueueStatus.all().filter('active_patch_id =', self.id).get()
        if not first_status:
            # We don't have any record of this attachment.
            return summary
        summary["bug_id"] = first_status.active_bug_id

        for queue in Queue.all():
            summary[queue.name_with_underscores()] = None
            status = QueueStatus.all().filter('queue_name =', queue.name()).filter('active_patch_id =', self.id).order('-date').get()
            if status:
                # summary() is a horrible API and should be killed.
                summary[queue.name_with_underscores()] = {
                    "state": self.state_from_queue_status(status),
                    "status": status,
                }
        return summary
Пример #17
0
 def _calculate_queue_positions(self):
     all_work_items = WorkItems.all().fetch(limit=len(Queue.all()))
     return dict([(items.queue.name(), items.display_position_for_attachment(self.id)) for items in all_work_items if items.queue])
Пример #18
0
 def _calculate_queue_positions(self):
     all_work_items = WorkItems.all().fetch(limit=len(Queue.all()))
     return dict([(items.queue.name(), items.display_position_for_attachment(self.id)) for items in all_work_items if items.queue])
Пример #19
0
 def get(self):
     template_values = {
         "queues": [QueueBubble(queue) for queue in Queue.all()],
     }
     self.response.out.write(template.render("templates/recentstatus.html", template_values))
Пример #20
0
 def get(self):
     template_values = {"queues": [QueueBubble(queue) for queue in Queue.all()]}
     self.response.out.write(template.render("templates/recentstatus.html", template_values))