diff --git a/src/features/StreamPlayer/hooks/index.tsx b/src/features/StreamPlayer/hooks/index.tsx index b107383a..7daced4b 100644 --- a/src/features/StreamPlayer/hooks/index.tsx +++ b/src/features/StreamPlayer/hooks/index.tsx @@ -116,6 +116,7 @@ export const useVideoPlayer = ({ playingOrder, playingProgress, playNextEpisode, + profile, selectedPlaylist, setCircleAnimation, setIsFullScreen, @@ -651,15 +652,28 @@ export const useVideoPlayer = ({ // ведем статистику просмотра матча const { start: startCollectingStats, stop: stopCollectingStats } = useInterval({ - callback: useCallback(() => { - if (timeForStatistics.current !== 0) { - saveMatchStats({ - matchId: profileId, - matchSecond: timeForStatistics.current, - sportType, - }) - } - }, [profileId, sportType]), + callback: useCallback( + () => { + if (timeForStatistics.current !== 0) { + saveMatchStats({ + matchDate: profile?.date, + matchId: profileId, + matchSecond: timeForStatistics.current, + seasonId: profile?.season.id, + sportType, + teamFirst: profile?.team1.id, + teamSecond: profile?.team2.id, + tournamentId: profile?.tournament.id, + }) + } + }, + [profile?.date, + profile?.season.id, + profile?.team1.id, profile?.team2.id, + profile?.tournament.id, + profileId, sportType, + ], + ), intervalDuration: VIEW_INTERVAL_MS, startImmediate: false, }) diff --git a/src/requests/saveMatchStats.tsx b/src/requests/saveMatchStats.tsx index b46dc1d4..c63d457f 100644 --- a/src/requests/saveMatchStats.tsx +++ b/src/requests/saveMatchStats.tsx @@ -3,26 +3,41 @@ import { VIEWS_API } from 'config' import { callApi } from 'helpers' type Props = { + matchDate?: string, matchId: number, matchSecond: number, + seasonId?: number, sportType: number, + teamFirst?: number, + teamSecond?: number, + tournamentId?: number, } export const VIEW_INTERVAL_MS = 5000 export const saveMatchStats = ({ + matchDate, matchId, matchSecond, + seasonId, sportType, + teamFirst, + teamSecond, + tournamentId, }: Props) => { - const url = `${VIEWS_API}/user/view` + const url = `${VIEWS_API}/v2/user/view` const config = { body: { - interval: VIEW_INTERVAL_MS / 1000, + duration: VIEW_INTERVAL_MS / 1000, + match_date: matchDate, match_id: matchId, + season: seasonId, second: matchSecond, sport_id: sportType, + team1: teamFirst, + team2: teamSecond, + tournament: tournamentId, }, }