import { rankingApi } from '../ranking-api';
import { storage } from 'src/storage';

export const updateMaster = async () => {
  const country = 'ALL';
  const age = 0;
  const ranking = 'nm';
  const pageSize = 50;
  const totalPages = 5;

  for (let page = 1; page <= totalPages; page++) {
    try {
      const response = await rankingApi.getMaster(country, age, ranking, pageSize, page);
      if (response.data) {
        const key = `masterRanking-${page}`;
        storage.set(key, JSON.stringify(response.data));
      }
    } catch (err) {
      break;
    }
  }
};
