Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leingenm committed Aug 31, 2024
1 parent 3bc8989 commit 24398a1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
10 changes: 3 additions & 7 deletions src/main/java/com/ypm/controller/LibraryImportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ public class LibraryImportController {

private final ImportService importService;

@PostMapping("/watchLater")
public ResponseEntity<String> importWatchLaterLibrary(@RequestParam("file") MultipartFile file) {
@PostMapping("/watch-later")
public ResponseEntity<String> importWatchLaterLibrary(@RequestParam("file") MultipartFile file) throws IOException {
if (file.isEmpty()) {
return ResponseEntity.badRequest().build();
}

List<VideoImport> savedVideos;
try {
savedVideos = importService.importCsv(file);
} catch (IOException e) {
throw new RuntimeException(e); // TODO: Update exception handling
}
savedVideos = importService.importCsv(file);

var responseBody = String.format("Saved %s videos", savedVideos.size());
return ResponseEntity.ok().body(responseBody);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ypm/controller/VideoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class VideoController {
private final VideoService videosService;
private final TokenService tokenService;

@PostMapping("/loadData")
@PostMapping("/load")
public ResponseEntity<List<VideoDto>> getVideoData(@RequestBody List<String> videoIds) throws IOException {
var videoData = videosService.getVideoData(videoIds);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ypm/persistence/entity/VideoImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class VideoImport {

public VideoImport(String videoId, String videoTimeStamp) {
this.videoId = videoId;
this.dateAdded = OffsetDateTime.parse(videoTimeStamp); // TODO: Is it okay solution?
this.dateAdded = OffsetDateTime.parse(videoTimeStamp);
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/ypm/service/youtube/ImportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class ImportService {
public List<VideoImport> importCsv(MultipartFile file) throws IOException {
final List<VideoImport> videos = new ArrayList<>();

// Parse CSV
try (var reader = new BufferedReader(new InputStreamReader(file.getInputStream()))) {
String line;
var header = true;
Expand All @@ -42,7 +41,6 @@ public List<VideoImport> importCsv(MultipartFile file) throws IOException {
}
}

// Save into DB
return videoRepository.saveAll(videos);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/ypm/service/youtube/VideoServiceImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void deleteVideo(String accessToken, String videoId) throws IOException {
public List<VideoDto> getVideoData(List<String> videoIds) throws IOException {
final int maxResults = 50;

// Remove duplicates from the incoming list with ids
// DEV-NOTE: Remove duplicates from the incoming list with ids
videoIds = videoIds.stream().distinct().toList();
var videoDtoList = new ArrayList<VideoDto>();

Expand Down

0 comments on commit 24398a1

Please sign in to comment.