Skip to content

Commit

Permalink
Makes the average vote meaningful by considering only those items wit…
Browse files Browse the repository at this point in the history
…h more than 200 votes.
  • Loading branch information
mbgspcii committed Jul 25, 2022
1 parent 42d38c1 commit 98d269f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion actions/getGenreMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as TYPES from './types';
import tmdbAPI from 'services/tmdbAPI';
import LINKS from 'utils/constants/links';
import { TMDB_API_VERSION } from 'config/tmdb';
import { SORT_BY_OPTIONS } from 'utils/constants/select-search';

const getGenreMovies = (genreId, page, sort) => async (
dispatch,
Expand All @@ -15,11 +16,13 @@ const getGenreMovies = (genreId, page, sort) => async (
}
try {
dispatch({type: TYPES.SET_MOVIES_LOADING});
const { vote_count } = SORT_BY_OPTIONS.find((s) => s.value === sort);
const response = await tmdbAPI.get(`/${TMDB_API_VERSION}/discover/movie`, {
params: {
with_genres: genreId,
page,
sort_by: sort
sort_by: sort,
"vote_count.gte":vote_count && vote_count.gte || 0,
}
});
await dispatch({
Expand Down
9 changes: 8 additions & 1 deletion utils/constants/select-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ const YES_OR_NO_OPTIONS = [

const SORT_BY_OPTIONS = [
{value: 'popularity.desc', name: 'Popularity'},
{value: 'vote_average.desc', name: 'Votes Average'},
{
value: 'vote_average.desc',
name: 'Votes Average',
vote_count : {
gte : 200
}
},
{value: 'original_title.asc', name: 'Original Title'},
{value: 'release_date.desc', name: 'Release Date'}
];


export {
YES_OR_NO_OPTIONS,
SORT_BY_OPTIONS
Expand Down

0 comments on commit 98d269f

Please sign in to comment.