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

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

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