Skip to content

Commit 801c5a6

Browse files
committed
remove test endpoints
1 parent 05b985b commit 801c5a6

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

src/main/java/app/betterhm/backend/v1/controller/MovieController.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22

33
import app.betterhm.backend.v1.component.MovieCache;
44
import app.betterhm.backend.v1.models.movies.Movie;
5-
import app.betterhm.backend.v1.services.MovieService;
65
import org.slf4j.Logger;
76
import org.slf4j.LoggerFactory;
87
import org.springframework.beans.factory.annotation.Autowired;
98
import org.springframework.web.bind.annotation.GetMapping;
109
import org.springframework.web.bind.annotation.RequestMapping;
1110
import org.springframework.web.bind.annotation.RestController;
1211

13-
import java.time.LocalDate;
1412
import java.util.List;
15-
import java.util.stream.Collectors;
1613

1714
@RestController
1815
@RequestMapping("/v1/movies")
1916
public class MovieController {
2017
private final MovieCache movieCache;
21-
private final MovieService movieService;
2218

2319
private final Logger logger = LoggerFactory.getLogger(MovieController.class);
2420

2521
@Autowired
26-
public MovieController(MovieCache movieCache, MovieService movieService) {
22+
public MovieController(MovieCache movieCache) {
2723
this.movieCache = movieCache;
28-
this.movieService = movieService;
2924
}
3025

3126
@GetMapping
@@ -34,19 +29,4 @@ public List<Movie> getMovies() {
3429
logger.info("Found {} movies", movies.size());
3530
return movies;
3631
}
37-
38-
@GetMapping("/fetch")
39-
public void fetch() {
40-
movieService.updateMovies();
41-
}
42-
43-
@GetMapping("/test")
44-
public List<Movie> test() {
45-
Movie movie = new Movie(
46-
"Inception", LocalDate.of(2010, 7, 16), "20:00", "FSK 12", "Sci-Fi", 148,
47-
"A mind-bending thriller", "The content of the movie", "Room A", "coverUrl",
48-
"coverBlurhash", "trailerUrl", "unifilmUrl"
49-
);
50-
return List.of(movie); // Return a list with one movie object for testing
51-
}
5232
}

src/main/java/app/betterhm/backend/v1/services/MovieService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.core.type.TypeReference;
88
import com.fasterxml.jackson.databind.ObjectMapper;
99
import io.trbl.blurhash.BlurHash;
10+
import jakarta.annotation.PostConstruct;
1011
import org.slf4j.Logger;
1112
import org.slf4j.LoggerFactory;
1213
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,8 +37,10 @@ public MovieService(MovieApiClient apiClient, ObjectMapper objectMapper, MovieCa
3637
this.movieCache = movieCache;
3738
}
3839

40+
/// Run after boot and every day at 06:00
3941
@Scheduled(cron = "0 0 6 * * *")
40-
public void updateMovies() {
42+
@PostConstruct
43+
private void updateMovies() {
4144
var rawJson = apiClient.fetchMovies();
4245
try {
4346
List<ExternalMovieModel> mapped = objectMapper
@@ -60,6 +63,7 @@ public void updateMovies() {
6063
}
6164
}
6265

66+
/// calculate blurhash of the image
6367
private String getCoverBlurhash(Movie m) throws IOException {
6468
logger.info("Fetching Cover for Movie {}", m.title());
6569
BufferedImage img = ImageIO.read(new URL(m.coverUrl()).openStream());

0 commit comments

Comments
 (0)