go-phie / ocena Goto Github PK
View Code? Open in Web Editor NEWAPI handling ratings for gophie-web
License: GNU General Public License v3.0
API handling ratings for gophie-web
License: GNU General Public License v3.0
Enable search and listing API endpoints (issue #2) to first try retrieve information from gophie core, if that fails then retrieve from database
A new way to identify users that replaces ip_addresses in the codebase
We can make sure the listing returns endpoints by most recent according to how it was posted on the app
We add a saved_on
column to Movie. Then since ocena is the one calling gophie, we can take the page number(when it is list)
We can now use it to set a datetime object on the returned object, e.g if the page number is 1, we set saved_on
to be a day behind... if it is page 2, we set saved_on
to be 2 days behind. This way, when we order by saved on
, recent movies will tend to cluster at the top and our listing wouldn't look like random selections...
Port to Async modules https://fastapi.tiangolo.com/advanced/async-sql-databases/
Move all requests about a movie to a database transaction
@router.post("/movie/ratings/average/", response_model=schemas.AverageRating)
def get_average_ratings(movie: schemas.MovieRating, db: Session = Depends(get_db)):
"""
Get average movie ratings and number of people who have rated
"""
return crud.get_movie_average_ratings(db=db, movie=movie)
@router.post("/movie/rating/", response_model=schemas.Rating)
def get_ip_rating(spec_rating: schemas.SpecificRating, db: Session = Depends(get_db)):
"""
Get Rating of a movie by an ip_address
"""
return crud.get_rating(db=db, spec_rating=spec_rating)
@router.post("/movie/downloads/", response_model=int)
def get_downloads(movie: schemas.MovieRating, db: Session = Depends(get_db)):
"""
Gets number of downloads of a movie
"""
return crud.get_number_of_downloads(db=db, movie=movie)
@router.post("/movie/referrals/", response_model=int)
def get_referrals(movie: schemas.MovieRating, db: Session = Depends(get_db)):
"""
Gets total number of referrals of a movie
"""
return crud.get_no_of_referrals(db=db, movie=movie)
All needs to be done when fetching movie data without makeing further requests
If gophie response is not 200 (like gophie is temporarily down) , we would need to clear cache else all the calls will be made to ocena for the next 24 hours even when gophie comes up
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.