package com.alterdekim.game.repository;

import com.alterdekim.game.entity.OnlineStatus;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface OnlineStatusRepository extends JpaRepository<OnlineStatus, Long> {

    @Query(value = "SELECT o FROM OnlineStatus o WHERE o.user.id = :userId")
    List<OnlineStatus> findByUserId(@Param("userId") Integer userId);

    @Query(value = "SELECT o FROM OnlineStatus o WHERE o.lastPingUnix < :pingTime")
    List<OnlineStatus> listPingsOlderThan(@Param("pingTime") Long pingTime);
}
