Skip to content

Commit

Permalink
Merge pull request #265 from fga-eps-mds/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nukdown authored Nov 13, 2018
2 parents 9b13e76 + c5d0a59 commit f553392
Show file tree
Hide file tree
Showing 18 changed files with 471 additions and 512 deletions.
1 change: 1 addition & 0 deletions CrossData/API/fixtures/data.json

Large diffs are not rendered by default.

425 changes: 424 additions & 1 deletion CrossData/API/models.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CrossData/API/objects_attrs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from CrossData.importdata.models import *
from CrossData.API.models import *

steam_attrs = list(vars(InfoSteam()).keys())
youtube_attrs = list(vars(InfoYoutube()).keys())
twitch_attrs = list(vars(InfoTwitch()).keys())
streams_attrs = list(vars(TwitchStream()).keys())
streams_attrs = list(vars(TwitchStream()).keys())
File renamed without changes.
2 changes: 1 addition & 1 deletion CrossData/API/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from CrossData.importdata.models import *
from CrossData.API.models import *

class EndpointPOSTTestCase(APITestCase):

Expand Down
4 changes: 2 additions & 2 deletions CrossData/API/tests_get_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from CrossData.importdata.models import *
from CrossData.API.models import *

class EndpointGETTestCase(APITestCase):

Expand All @@ -21,7 +21,7 @@ def test_graphic_status_code(self):

def test_graphic_return_json(self):

json_ideal_return = {'x_axys': [], 'y_axys': []}
json_ideal_return = {'x_axis': [], 'y_axis': []}
response = self.client.get(self.url_graphic)
self.assertEqual(response.data, json_ideal_return)

Expand Down
69 changes: 34 additions & 35 deletions CrossData/API/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from rest_framework.response import Response
from rest_framework import status
from rest_framework.views import APIView
from CrossData.importdata.models import *
from CrossData.importdata.serializers import *
from CrossData.API.models import *
from CrossData.API.serializers import *
from .objects_attrs import *
from urllib.parse import unquote
from operator import itemgetter
Expand Down Expand Up @@ -74,7 +74,7 @@ def get_tranding_now_data(self):
return self.get_data(games)

def get_most_watched_data(self):

games = Game.objects.all().order_by(
'-infoyoutube__count_views',
'-infoyoutube__count_videos',
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_data(self, games):
collected_data.append(game_data)

return collected_data



class GetGraphicData(APIView):
Expand All @@ -127,11 +127,11 @@ def get(self, request, graphtype, yaxis, xaxis, name=None, format=None):

if name==None:
if graph_type == "line":
data = self.get_line_axys(y_axis, x_axis, data)
data = self.get_line_axis(y_axis, x_axis, data)

else:
game = self.get_game(name)
data['x_axys'] = self.get_dates(game)
data['x_axis'] = self.get_dates(game)
data['y_axis'] = self.get_game_y_axis(game, y_axis)

return Response(data=data, status=status.HTTP_200_OK)
Expand All @@ -140,7 +140,7 @@ def get_game_y_axis(self, game, y_axis):

y_axis_data = []
infos = []

if y_axis in steam_attrs:
infos = InfoSteam.objects.all().filter(game=game)
elif y_axis in youtube_attrs:
Expand All @@ -149,7 +149,7 @@ def get_game_y_axis(self, game, y_axis):
infos = InfoTwitch.objects.all().filter(game=game)
elif y_axis in streams_attrs:
infos = TwitchStream.objects.all().filter(game=game)

y_axis_data = self.get_data(infos, y_axis)

return y_axis_data
Expand All @@ -167,63 +167,63 @@ def get_dates(self, game):
return dates

def get_game(self, game_name):

game = Game.objects.get(name=game_name)
return game

def get_line_axys(self, y_axys, x_axys, game_data):
def get_line_axis(self, y_axis, x_axis, game_data):

if x_axys == 'games' or y_axys=='games':
game_data['x_axys'] = self.get_games_name()
if x_axis == 'games' or y_axis=='games':
game_data['x_axis'] = self.get_games_name()

if y_axys in steam_attrs:
game_data['y_axys'] = self.get_data(
if y_axis in steam_attrs:
game_data['y_axis'] = self.get_data(
InfoSteam.objects.order_by('-owners','-positive_reviews_steam', 'average_2weeks')[:20],
y_axys
y_axis
)
if x_axys in steam_attrs:
game_data['x_axys'] = self.get_data(
if x_axis in steam_attrs:
game_data['x_axis'] = self.get_data(
InfoSteam.objects.order_by('-owners','-positive_reviews_steam', 'average_2weeks')[:20],
x_axys
x_axis
)

if y_axys in youtube_attrs:
game_data['y_axys'] = self.get_data(
if y_axis in youtube_attrs:
game_data['y_axis'] = self.get_data(
InfoYoutube.objects.all().order_by(
'-game__infosteam__owners',
'-game__infosteam__positive_reviews_steam',
'-game__infosteam__average_2weeks',
)[:20],
y_axys
y_axis
)
if x_axys in youtube_attrs:
game_data['x_axys'] = self.get_data(

if x_axis in youtube_attrs:
game_data['x_axis'] = self.get_data(
InfoYoutube.objects.all().order_by(
'-game__infosteam__owners',
'-game__infosteam__positive_reviews_steam',
'-game__infosteam__average_2weeks',
)[:20],
x_axys
x_axis
)

if y_axys in twitch_attrs:
game_data['y_axys'] = self.get_data(
if y_axis in twitch_attrs:
game_data['y_axis'] = self.get_data(
InfoTwitch.objects.all().order_by(
'-game__infosteam__owners',
'-game__infosteam__positive_reviews_steam',
'-game__infosteam__average_2weeks',
)[:20],
y_axys
y_axis
)
if x_axys in twitch_attrs:
game_data['x_axys'] = self.get_data(
if x_axis in twitch_attrs:
game_data['x_axis'] = self.get_data(
InfoTwitch.objects.all().order_by(
'-game__infosteam__owners',
'-game__infosteam__positive_reviews_steam',
'-game__infosteam__average_2weeks',
)[:20],
x_axys
x_axis
)

return game_data
Expand Down Expand Up @@ -329,7 +329,7 @@ def all_data(self, game):
data.update(genres_dict)
data.update({'streams': streams_array})
data.update({'screenshots': screenshots_array})

if data["release_date"] != None:
data["release_date"] = data["release_date"].split('T')[0]

Expand Down Expand Up @@ -548,7 +548,7 @@ def save_palettes(self, screenshot_data, screenshot):
def get_release_data(self, str_date):
if str_date == None:
return

tmp_datetime = dateutil.parser.parse(str_date)

return tmp_datetime.date()
Expand All @@ -563,7 +563,7 @@ class GenreColors(APIView):
def get(self, request, format=None):
genre_name = request.GET.get('genre')
color_name = request.GET.get('color')

genre = Genre.objects.get(genre=genre_name)

colors_array = []
Expand All @@ -577,4 +577,3 @@ def get(self, request, format=None):
class Genres(APIView):
def get(self, request, format=None):
return Response(GenreSerializer(Genre.objects.all(), many=True).data)

Empty file removed CrossData/importdata/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions CrossData/importdata/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions CrossData/importdata/apps.py

This file was deleted.

1 change: 0 additions & 1 deletion CrossData/importdata/fixtures/data.json

This file was deleted.

Loading

0 comments on commit f553392

Please sign in to comment.