Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the average vote meaningful by considering only those items with more than 200 votes. #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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