Changeset a8b6e6a for src/main/java/com


Ignore:
Timestamp:
02/10/23 19:30:53 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
11d7b36
Parents:
633b371
Message:

Update HomeController.java

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/web/HomeController.java

    r633b371 ra8b6e6a  
    2222import java.io.IOException;
    2323import java.time.LocalDate;
     24import java.util.Collections;
    2425import java.util.LinkedList;
    2526import java.util.List;
     
    7172    public String getHomePage(Model model) {
    7273        List<Film> films=filmService.findAllFilms();
     74        Collections.reverse(films);
    7375        films=films.stream().limit(5).collect(Collectors.toList());
    74         List <Event> events=eventService.findAllEvents().stream().limit(5).collect(Collectors.toList());
     76        List <Event> events=eventService.findAllEvents();
     77        Collections.reverse(events);
     78        events=events.stream().limit(5).collect(Collectors.toList());
    7579        model.addAttribute("films", films);
    7680        model.addAttribute("events",events);
     
    8589        List<String> genres= List.of(film.getGenre().split(","));
    8690        double r=customerRatesFilmService.avg_rating(film.getId_film());
     91        Double ra=Double.valueOf(r);
     92        if(ra==null){
     93            r=0;
     94        }
    8795        model.addAttribute("rating",r);
    8896        model.addAttribute("genres", genres);
Note: See TracChangeset for help on using the changeset viewer.