Exemple #1
0
 def get(self):
     name = request.args.get('name')
     if name is not None and len(name) <= 0:
         abort(400)
     data = GraphQuery.getOtherActors(GraphQuery(), InitGraph.actorNodes,
                                      name)
     return {'actors': [act for act in data]}
Exemple #2
0
def get_actor_age(actor_name):
    age = GraphQuery.getActorAge(GraphQuery(), InitGraph.actorNodes,
                                 actor_name)
    if age is None:
        print("Invalid Actor!")
    else:
        print('Age: {0:s}'.format(age))
Exemple #3
0
def get_film_value(film_name):
    value = GraphQuery.getFilmValue(GraphQuery(), InitGraph.filmNodes,
                                    film_name)
    if value is None:
        print("Invalid Film!")
    else:
        print('Gross Value: {0:s}'.format(value))
Exemple #4
0
 def get(self):
     name = request.args.get('name')
     if len(name) <= 0:
         abort(400)
     data = GraphQuery.getOtherFilms(GraphQuery(), InitGraph.filmNodes,
                                     name)
     return {'films': [film for film in data]}
Exemple #5
0
 def delete(self, film_name):
     if len(film_name) <= 0:
         abort(400)
     GraphQuery.removeFilm(GraphQuery(), InitGraph.filmNodes,
                           InitGraph.filmNameDict, film_name)
     response = make_response(jsonify({'result': True}), 200)
     return {'Status': response.status_code}
Exemple #6
0
 def post(self):
     data = self.reqparse.parse_args()
     if len(data['name']) <= 0:
         abort(400)
     GraphQuery.addActor(GraphQuery(), InitGraph.actorNodes,
                         InitGraph.actorNameDict, data['name'], data['age'])
     response = make_response(jsonify(data), 200)
     return {'Status': response.status_code}
Exemple #7
0
def get_films_in_year(year):
    films = GraphQuery.getAllFilmsInYear(GraphQuery(), InitGraph.filmNodes,
                                         year)
    if films is None:
        print("Invalid Year!")
    else:
        for film in films:
            print(film)
Exemple #8
0
def get_actors_in_year(year):
    actors = GraphQuery.getAllActorsInYear(GraphQuery(), InitGraph.actorNodes,
                                           year)
    if actors is None:
        print("Invalid Year!")
    else:
        for actor in actors:
            print(actor)
Exemple #9
0
def get_actor_castings(actor_name):
    films = GraphQuery.getActorCastings(GraphQuery(), InitGraph.actorNameDict,
                                        actor_name)
    if films is None:
        print("Invalid Actor!")
    else:
        print('Castings in:')
        for film in films:
            print(film)
Exemple #10
0
def get_film_starrings(film_name):
    actors = GraphQuery.getActorsInFilm(GraphQuery(), InitGraph.filmNameDict,
                                        film_name)
    if actors is None:
        print("Invalid Film!")
    else:
        print('Starrings in:')
        for actor in actors:
            print(actor)
Exemple #11
0
 def post(self):
     # pdb.set_trace()
     data = self.reqparse.parse_args()
     if len(data['name']) <= 0:
         abort(400)
     GraphQuery.addFilm(GraphQuery(), InitGraph.filmNodes,
                        InitGraph.filmNameDict, data['name'], data['value'])
     response = make_response(jsonify(data), 200)
     return {'Status': response.status_code}
Exemple #12
0
def show_hub_actors():
    hub = {}
    for film in InitGraph.filmNameDict.keys():
        if film is not None:
            actors = GraphQuery.getActorsInFilm(GraphQuery(),
                                                InitGraph.filmNameDict, film)
            for actor in actors:
                hub[actor] = len(actors)
    labels = list(hub.keys())
    values = list(hub.values())
    trace = go.Pie(labels=labels, values=values)
    py.plot([trace], filename='basic_pie_chart')
Exemple #13
0
 def get(self, actor_name):
     if len(actor_name) <= 0:
         abort(400)
     age = GraphQuery.getActorAge(GraphQuery(), InitGraph.actorNodes,
                                  actor_name)
     castings = GraphQuery.getActorCastings(GraphQuery(),
                                            InitGraph.actorNameDict,
                                            actor_name)
     data = {
         'actor_name': actor_name,
         'actor_age': age,
         'actor_castings': castings
     }
     return make_response(jsonify({'actors': marshal(data, actor_field)}),
                          200)
Exemple #14
0
 def get(self, film_name):
     if len(film_name) <= 0:
         abort(400)
     value = GraphQuery.getFilmValue(GraphQuery(), InitGraph.filmNodes,
                                     film_name)
     starrings = GraphQuery.getActorsInFilm(GraphQuery(),
                                            InitGraph.filmNameDict,
                                            film_name)
     data = {
         'film_name': film_name,
         'film_value': value,
         'film_starrings': starrings
     }
     return make_response(jsonify({'films': marshal(data, film_field)}),
                          200)
Exemple #15
0
def show_age_gross_relation():
    ret = {}
    for film in InitGraph.filmNodes:
        if film is not None:
            value = FilmNode.getValue(film)
            name = FilmNode.getName(film)
            actors = GraphQuery.getActorsInFilm(GraphQuery(),
                                                InitGraph.filmNameDict, name)
            for actor in actors:
                if actor is not None:
                    for node in InitGraph.actorNodes:
                        if ActorNode.getName(node) == actor:
                            ret[ActorNode.getAge(node)] = value

    trace = go.Pie(labels=list(ret.keys()), values=list(ret.values()))
    py.plot([trace], filename='basic_pie_chart')
Exemple #16
0
def show_actor_earnings():
    ret = {}
    for film in InitGraph.filmNodes:
        if film is not None:
            value = float(FilmNode.getValue(film))
            name = FilmNode.getName(film)
            actors = GraphQuery.getActorsInFilm(GraphQuery(),
                                                InitGraph.filmNameDict, name)
            for actor in actors:
                if actor is not None:
                    if ret.get(actor) is None:
                        ret[actor] = 0.0
                    ret[actor] += value

    labels = list(ret.keys())
    values = list(ret.values())
    trace = go.Pie(labels=labels, values=values)
    py.plot([trace], filename='basic_pie_chart')
Exemple #17
0
 def put(self, actor_name):
     if len(actor_name) <= 0:
         abort(400)
     age = GraphQuery.getActorAge(GraphQuery(), InitGraph.actorNodes,
                                  actor_name)
     castings = GraphQuery.getActorCastings(GraphQuery(),
                                            InitGraph.actorNameDict,
                                            actor_name)
     data = {
         'actor_name': actor_name,
         'actor_age': age,
         'actor_castings': castings
     }
     args = request.get_json()
     if args is not None:
         for k, v in args.items():
             if v is not None:
                 data[k] = v
     return {'actors': data}
Exemple #18
0
 def put(self, film_name):
     if len(film_name) <= 0:
         abort(400)
     value = GraphQuery.getFilmValue(GraphQuery(), InitGraph.filmNodes,
                                     film_name)
     starrings = GraphQuery.getActorsInFilm(GraphQuery(),
                                            InitGraph.filmNameDict,
                                            film_name)
     data = {
         'film_name': film_name,
         'film_value': value,
         'film_starrings': starrings
     }
     args = request.get_json()
     if args is not None:
         for k, v in args.items():
             if v is not None:
                 data[k] = v
     return {'films': data}
Exemple #19
0
def get_film_most_value():
    name = GraphQuery.getMaxBoxOfficeFilm(GraphQuery(), InitGraph.filmNodes)
    if name is None:
        print("Invalid Film!")
    else:
        print('Film with max Box Office: {0:s}'.format(name))
Exemple #20
0
def get_oldest_actor():
    name = GraphQuery.getOldestActor(GraphQuery(), InitGraph.actorNodes)
    if name is None:
        print("Invalid Actor!")
    else:
        print('Oldest Actor: {0:s}'.format(name))
Exemple #21
0
 def delete(self, actor_name):
     GraphQuery.removeActor(GraphQuery(), InitGraph.actorNodes,
                            InitGraph.actorNameDict, actor_name)
     response = make_response(jsonify({'result': True}), 200)
     return {'Status': response.status_code}