import { rankingQueryKeys } from '../ranking-query-keys';
import { type PostGetRanking, rankingApi } from '../ranking-api';
import { queryClient } from 'src/utils/queryClient';

export const fetchInHistory = async () => {
  try {
    const data: PostGetRanking = await queryClient.fetchQuery({
      queryKey: rankingQueryKeys.getInHistory(),
      queryFn: async () => {
        const response = await rankingApi.getInHistory();
        return response.data;
      },
      gcTime: 0,
      staleTime: 0
    });

    return data;
  } catch (error) {
    console.error('Failed to fetch in-history data:', error);
  }
};
