Exemplo n.º 1
0
 def get_context_data(self, datestamp):
     context = super().get_context_data()
     livetvusername = self.request.user.userprofile.livetvusername
     day_nodes = Node.objects.filter(livetvusername=livetvusername, timestamp__contains=datetime.datetime.strptime(datestamp, "%Y-%m-%d").date())
     x_data, y_data = unzip_data(prepare_data_for_plot(day_nodes.values_list("timestamp", "current_total")))
     context["breakdown"] = daily_aggregator(day_nodes)[0]
     context["y_data"] = y_data
     context["x_data"] = x_data
     context["max_y"] = max(y_data)
     return context
Exemplo n.º 2
0
 def get_context_data(self, user_slug, datestamp):
     context = super().get_context_data()
     day_nodes = Node.objects.filter(livetvusername=user_slug, timestamp__contains=datetime.datetime.strptime(datestamp, "%Y-%m-%d").date())
     x_data, y_data = unzip_data(prepare_data_for_plot(day_nodes.values_list("timestamp", "current_total")))
     context["breakdown"] = daily_aggregator(day_nodes)[0]
     context["y_data"] = y_data
     context["x_data"] = x_data
     context["max_y"] = max(y_data)
     context["admin_viewing"] = True
     context["admin_viewing_user"] = user_slug
     return context
Exemplo n.º 3
0
 def get_context_data(self, datestamp):
     context = super().get_context_data()
     day = datetime.datetime.strptime(datestamp, "%Y-%m-%d").date()
     livetvusername = self.request.user.userprofile.livetvusername
     day_nodes = Node.objects.filter(livetvusername=livetvusername, timestamp__contains=day)
     x_data, y_data = unzip_data(prepare_data_for_plot(day_nodes.values_list("timestamp", "current_total"), livetvusername))
     context["breakdown"] = daily_aggregator(day_nodes)[0]
     context["y_data"] = y_data
     context["x_data"] = x_data
     context["videos"] = [vid for generator in LiveCodingClient(livetvusername).get_user_videos() for vid in generator if datetime.datetime.strptime(vid.creation_time[:10], "%Y-%m-%d").date() == day]
     context["max_y"] = max(y_data)
     return context
Exemplo n.º 4
0
 def get_context_data(self, datestamp):
     context = super().get_context_data()
     livetvusername = self.request.user.userprofile.livetvusername
     day_nodes = Node.objects.filter(
         livetvusername=livetvusername, timestamp__contains=datetime.datetime.strptime(datestamp, "%Y-%m-%d").date()
     )
     x_data, y_data = unzip_data(prepare_data_for_plot(day_nodes.values_list("timestamp", "current_total")))
     context["breakdown"] = daily_aggregator(day_nodes)[0]
     context["y_data"] = y_data
     context["x_data"] = x_data
     context["max_y"] = max(y_data)
     return context
Exemplo n.º 5
0
    def get_context_data(self, user_slug, datestamp):
        context = super().get_context_data()
        day = datetime.datetime.strptime(datestamp, "%Y-%m-%d").date()
        day_nodes = Node.objects.filter(livetvusername=user_slug, timestamp__contains=datetime.datetime.strptime(datestamp, "%Y-%m-%d").date())
        x_data, y_data = unzip_data(prepare_data_for_plot(day_nodes.values_list("timestamp", "current_total"), user_slug))
        context["breakdown"] = daily_aggregator(day_nodes)[0]
        context["y_data"] = y_data
        context["x_data"] = x_data
        context["max_y"] = max(y_data)
        context["admin_viewing"] = True
        context["admin_viewing_user"] = user_slug

        # Won't work if someone hasn't authenticated with API. Fail gracefully?
        # try:
        #     context["videos"] = [vid for generator in LiveCodingClient(user_slug).get_user_videos() for vid in generator if datetime.datetime.strptime(vid.creation_time, "%Y-%m-%dT%H:%M:%S.%fZ").date() == day]
        # except ApiAccessToken.DoesNotExist:
        #     pass
        return context
Exemplo n.º 6
0
 def get_context_data(self, datestamp):
     context = super().get_context_data()
     day = datetime.datetime.strptime(datestamp, "%Y-%m-%d").date()
     livetvusername = self.request.user.userprofile.livetvusername
     day_nodes = Node.objects.filter(livetvusername=livetvusername,
                                     timestamp__contains=day)
     x_data, y_data = unzip_data(
         prepare_data_for_plot(
             day_nodes.values_list("timestamp", "current_total"),
             livetvusername))
     context["breakdown"] = daily_aggregator(day_nodes)[0]
     context["y_data"] = y_data
     context["x_data"] = x_data
     context["videos"] = [
         vid for generator in LiveCodingClient(
             livetvusername).get_user_videos()
         for vid in generator if datetime.datetime.strptime(
             vid.creation_time[:10], "%Y-%m-%d").date() == day
     ]
     context["max_y"] = max(y_data)
     return context
Exemplo n.º 7
0
 def get_all_plottable_user_nodes(self, user):
     nodes = self.get_all_user_nodes(user).values_list('timestamp', 'current_total')
     return prepare_data_for_plot(nodes, user)
Exemplo n.º 8
0
 def get_all_plottable_user_nodes(self, user):
     nodes = self.get_all_user_nodes(user).values_list(
         'timestamp', 'current_total')
     return prepare_data_for_plot(nodes)