Skip to content

Commit

Permalink
Merge pull request #41 from ThePandaDevs/fix/vacants
Browse files Browse the repository at this point in the history
fix: Add only show vacants on active period (dates)
  • Loading branch information
HectorSaldes authored Aug 25, 2022
2 parents 7dae0b7 + a76b691 commit 65e7193
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Repository
public interface VacantRepository extends JpaRepository<Vacant, Integer> {
List<Vacant> findAllByActiveIsTrueAndIsPublicIsTrue();
List<Vacant> findAllByActiveIsTrueAndIsPublicIsTrueAndEndDateGreaterThanEqual(LocalDateTime time);
Optional<Vacant> findByIdAndActiveIsTrue(Integer id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -64,7 +65,8 @@ public VacantService(VacantMapper mapper) {

@Transactional(readOnly = true)
public List<VacantDto> getAll() {
return mapper.toVacantsDto(vacantRepository.findAllByActiveIsTrueAndIsPublicIsTrue());
LocalDateTime nowTime = LocalDateTime.now();
return mapper.toVacantsDto(vacantRepository.findAllByActiveIsTrueAndIsPublicIsTrueAndEndDateGreaterThanEqual(nowTime));
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 65e7193

Please sign in to comment.