Skip to content

Commit

Permalink
Improve discover movies sorting by release dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Nov 21, 2023
1 parent 0ba3c08 commit 5f1d7dd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions frontend/src/Store/Actions/discoverMovieActions.js
@@ -1,4 +1,5 @@
import _ from 'lodash';
import moment from 'moment/moment';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import { filterBuilderTypes, filterBuilderValueTypes, filterTypes, sortDirections } from 'Helpers/Props';
Expand Down Expand Up @@ -219,6 +220,42 @@ export const defaultState = {
const { ratings = {} } = item;

return ratings.tmdb? ratings.tmdb.value : 0;
},

inCinemas: function(item, direction) {
if (item.inCinemas) {
return moment(item.inCinemas).unix();
}

if (direction === sortDirections.DESCENDING) {
return -1 * Number.MAX_VALUE;
}

return Number.MAX_VALUE;
},

physicalRelease: function(item, direction) {
if (item.physicalRelease) {
return moment(item.physicalRelease).unix();
}

if (direction === sortDirections.DESCENDING) {
return -1 * Number.MAX_VALUE;
}

return Number.MAX_VALUE;
},

digitalRelease: function(item, direction) {
if (item.digitalRelease) {
return moment(item.digitalRelease).unix();
}

if (direction === sortDirections.DESCENDING) {
return -1 * Number.MAX_VALUE;
}

return Number.MAX_VALUE;
}
},

Expand Down

0 comments on commit 5f1d7dd

Please sign in to comment.