Skip to content

Commit

Permalink
update rating for duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
teticio committed Oct 11, 2021
1 parent 5cd5cd1 commit b6c22b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,15 @@ def create_playlist(playlist: schemas.Playlist, db: Session = Depends(get_db)):
db_item = db.query(models.Playlist).filter(
models.Playlist.hash == models.Playlist.hash_it(playlist))
db_item.update({'created': playlist.created})
if playlist.num_ratings > 0:
db_item.update({
'num_ratings':
db_item.first().num_ratings + playlist.num_ratings,
'av_rating':
(db_item.first().av_rating * db_item.first().num_ratings +
playlist.av_rating * playlist.num_ratings) /
(db_item.first().num_ratings + playlist.num_ratings)
})
db.commit() # Doesn't call hook but that's ok
db_item = db_item.first()
return db_item
Expand Down
3 changes: 2 additions & 1 deletion src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const prefix = Linking.createURL('/');
global.Buffer = global.Buffer || require('buffer').Buffer;
global.localStorage = global.localStorage || require('localStorage');

process.env.REACT_APP_API_URL = 'https://deej-ai.online/api/v1';
//process.env.REACT_APP_API_URL = 'https://deej-ai.online/api/v1';
process.env.REACT_APP_API_URL = 'http://192.168.0.243:8001/api/v1';

const theme = {
...DarkTheme,
Expand Down

0 comments on commit b6c22b9

Please sign in to comment.