def get(self, request): livetvusername = request.user.userprofile.livetvusername dataX, dataY, siteY = unzip_data(Node.objects.get_plottable_eight_minutes(livetvusername)) last_node = Node.objects.filter(livetvusername=livetvusername).last() current_count = 0 if last_node: current_count = last_node.current_total context = {"trending": trending(dataY), "frontpaged": request.user.userprofile.frontpaged, "maxY": max(dataY), "maxSiteY": max(siteY), "dataX": dataX, "dataY": dataY, "siteY": siteY, "current_count": current_count} return HttpResponse(json.dumps(context), content_type="application/json")
def get_context_data(self): context = super().get_context_data() livetvusername = self.request.user.userprofile.livetvusername last_node = Node.objects.get_all_user_nodes(livetvusername).last() if last_node: if last_node.timestamp < django_timezone.now() + datetime.timedelta(minutes=-1): return context current_node = last_node data = Node.objects.get_plottable_eight_minutes(livetvusername) if data: dataX, dataY, siteY = unzip_data(data) max_viewer_count = max([_[1] for _ in data]) trending_pattern = trending(dataY) context["trending"] = trending_pattern context["current_node"] = current_node context["max_viewer_count"] = max_viewer_count return context
def get(self, request): livetvusername = request.user.userprofile.livetvusername dataX, dataY, siteY = unzip_data( Node.objects.get_plottable_eight_minutes(livetvusername)) last_node = Node.objects.filter(livetvusername=livetvusername).last() current_count = 0 if last_node: current_count = last_node.current_total context = { "trending": trending(dataY), "frontpaged": request.user.userprofile.frontpaged, "maxY": max(dataY), "maxSiteY": max(siteY), "dataX": dataX, "dataY": dataY, "siteY": siteY, "current_count": current_count } return HttpResponse(json.dumps(context), content_type="application/json")
def get_context_data(self): context = super().get_context_data() livetvusername = self.request.user.userprofile.livetvusername all_nodes = Node.objects.get_all_user_nodes(livetvusername) if all_nodes: current_node = all_nodes.last() data = Node.objects.get_plottable_eight_minutes(livetvusername) if data: dataX, dataY, siteY = unzip_data(data) max_viewer_count = 0 trending_pattern = False if data: max_viewer_count = max([_[1] for _ in data]) trending_pattern = trending(dataY) context["trending"] = trending_pattern context["current_node"] = current_node context["max_viewer_count"] = max_viewer_count if not self.request.user.userprofile.active: context["daily_breakdown"] = daily_aggregator(all_nodes) return context