From 2f1fe305e7c40128e4ec372136d54d3f9cf9c8cb Mon Sep 17 00:00:00 2001 From: mjrode Date: Sat, 6 Apr 2019 02:50:58 -0500 Subject: [PATCH] List view with tv shows --- client/src/components/MediaList.js | 44 ++++++++++++++++++------------ server/services/recommend/index.js | 2 +- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/client/src/components/MediaList.js b/client/src/components/MediaList.js index 4a47e8d..1045a14 100644 --- a/client/src/components/MediaList.js +++ b/client/src/components/MediaList.js @@ -6,32 +6,40 @@ import styles from './css'; import axios from 'axios'; class MediaList extends Component { + state = {tvShowList: []}; + componentDidMount() { this.getMostWatched(); } getMostWatched = async params => { const res = await axios.get('/api/recommend/most-watched'); - console.log(res); - return res; + this.setState({tvShowList: res.data}); }; render() { - const {classes} = this.props; - return ( - - ); + const mediaList = this.state.tvShowList.map(show => { + return ( + + ); + }); + return
{mediaList}
; } } diff --git a/server/services/recommend/index.js b/server/services/recommend/index.js index b5c68ae..a6e3f4b 100644 --- a/server/services/recommend/index.js +++ b/server/services/recommend/index.js @@ -6,7 +6,7 @@ const getMostWatched = async (req, res) => { try { console.log('mike'); const mostWatched = await models.PlexLibrary.findAll({ - where: {UserId: req.user.id, views: {[Op.gt]: 0}}, + where: {UserId: req.user.id, type: 'show', views: {[Op.gt]: 0}}, }); console.log('mostwatched', mostWatched); res.json(mostWatched);