package com.davos.assessment.assessment;

import com.davos.assessment.user.AppUser;
import com.davos.assessment.project.Project;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface SubmissionRepository extends JpaRepository<Submission, Long> {
  List<Submission> findByUserOrderBySubmittedAtDesc(AppUser user);
  List<Submission> findByProjectAndUserOrderBySubmittedAtDesc(Project project, AppUser user);
  List<Submission> findByUserAndAssessmentOrderBySubmittedAtDesc(AppUser user, Assessment assessment);
  List<Submission> findByProjectAndUserAndAssessmentOrderBySubmittedAtDesc(Project project, AppUser user, Assessment assessment);
  long countByUserAndAssessment(AppUser user, Assessment assessment);
  long countByProjectAndUserAndAssessment(Project project, AppUser user, Assessment assessment);
  long countByProject(Project project);
  List<Submission> findAllByOrderBySubmittedAtDesc();
  List<Submission> findByProjectOrderBySubmittedAtDesc(Project project);
  Optional<Submission> findFirstByUserOrderBySubmittedAtDesc(AppUser user);
  List<Submission> findByUserIdInOrderBySubmittedAtDesc(Collection<Long> userIds);
  List<Submission> findByProjectAndUserIdInOrderBySubmittedAtDesc(Project project, Collection<Long> userIds);
}
