You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
overseerr/src/utils/creditHelpers.ts

25 lines
576 B

import { Crew } from '../../server/models/common';
const priorityJobs = [
'Director',
'Creator',
'Screenplay',
'Writer',
'Composer',
'Editor',
'Producer',
'Co-Producer',
'Executive Producer',
'Animation',
];
export const sortCrewPriority = (crew: Crew[]): Crew[] => {
return crew
.filter((person) => priorityJobs.includes(person.job))
.sort((a, b) => {
const aScore = priorityJobs.findIndex((job) => job.includes(a.job));
const bScore = priorityJobs.findIndex((job) => job.includes(b.job));
return aScore - bScore;
});
};