Skip to content

Commit

Permalink
🔧 Filter the schedule that can not mapped to any movie in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Nov 12, 2023
1 parent a08bd91 commit 5579a70
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/data/cacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ export default class cacheManager {
console.time('setMoviesSchedulesCache');
try {
const allSchedules = await getMoviesSchedules();
cacheManager.set(cacheManager.MOVIES_SCHEDULES, allSchedules);
// currently the schedules here has some data that could not mapped to LINE's movie title
// TODO: get the schedule directly from LINE so we don't need this filter, and the display will be more accurate
const recentMovieChineseTitles: string[] = cacheManager
.get(cacheManager.RECENT_MOVIES)
.map((movie) => movie.chineseTitle);
const filterdSchedules = allSchedules.filter(
(schedule) => recentMovieChineseTitles.indexOf(schedule.movieName) !== -1
);
cacheManager.set(cacheManager.MOVIES_SCHEDULES, filterdSchedules);
} catch (ex) {
console.error(ex);
}
Expand Down

0 comments on commit 5579a70

Please sign in to comment.