diff --git a/pom.xml b/pom.xml
index 46f9a57..e67596c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,7 +57,7 @@
2.2.0
- docker.io/rlkamradt/readnew
+ docker.io/rlkamradt/readnews
diff --git a/src/main/java/net/kamradtfamily/readnews/Inserts.java b/src/main/java/net/kamradtfamily/readnews/Inserts.java
index acca79c..958d1dc 100644
--- a/src/main/java/net/kamradtfamily/readnews/Inserts.java
+++ b/src/main/java/net/kamradtfamily/readnews/Inserts.java
@@ -33,24 +33,24 @@
*/
@Data
public class Inserts {
- @Id String id;
- String status;
- Integer totalResults;
- List articles;
+ private @Id String id;
+ private String status;
+ private Integer totalResults;
+ private List articles;
@Data
public static class Articles {
- Source source;
- String author;
- String title;
- String description;
- String url;
- String urlToImage;
- String publishedAt;
- String content;
+ private Source source;
+ private String author;
+ private String title;
+ private String description;
+ private String url;
+ private String urlToImage;
+ private String publishedAt;
+ private String content;
}
@Data
public static class Source {
- String id;
- String name;
+ private String id;
+ private String name;
}
}
diff --git a/src/main/java/net/kamradtfamily/readnews/ReadHeadlinesControllerV1.java b/src/main/java/net/kamradtfamily/readnews/ReadHeadlinesControllerV1.java
index 0a0f459..8836254 100644
--- a/src/main/java/net/kamradtfamily/readnews/ReadHeadlinesControllerV1.java
+++ b/src/main/java/net/kamradtfamily/readnews/ReadHeadlinesControllerV1.java
@@ -23,9 +23,7 @@
*/
package net.kamradtfamily.readnews;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.time.Instant;
-import java.time.LocalDate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
@@ -42,13 +40,11 @@
@RequestMapping("/v1/headlines")
public class ReadHeadlinesControllerV1 {
private static final int MAX_LIMIT = 1000;
-
+
private final InsertsReactiveRepository newsReactiveRepository;
- private final ObjectMapper objectMapper;
- ReadHeadlinesControllerV1(final InsertsReactiveRepository newsReactiveRepository,
- ObjectMapper objectMapper) {
+
+ ReadHeadlinesControllerV1(final InsertsReactiveRepository newsReactiveRepository) {
this.newsReactiveRepository = newsReactiveRepository;
- this.objectMapper = objectMapper;
}
@GetMapping(path="", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@@ -58,18 +54,18 @@ Flux getFromMongo(final Instant from, final Instant to, final
: limit;
return newsReactiveRepository
.findAll()
- .flatMap(r -> Flux.fromIterable(r.articles))
+ .flatMap(r -> Flux.fromIterable(r.getArticles()))
.filter(r -> filterByDate(r, from, to))
.limitRequest(actualLimit);
}
private boolean filterByDate(final Inserts.Articles record, final Instant from, Instant to) {
- if(record == null || record.publishedAt == null) {
+ if(record == null || record.getPublishedAt() == null) {
return false;
}
Instant theDate;
try {
- theDate = Instant.parse(record.publishedAt);
+ theDate = Instant.parse(record.getPublishedAt());
} catch(Exception ex) {
return false;
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index eaf7a10..4cf6489 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,2 +1,7 @@
-spring.data.mongodb.uri: mongodb\://admin\:admin@localhost\:27017/news?authSource=admin
+mongo.host: localhost
+mongo.user: admin
+mongo.pass: admin
+mongo.port: 27017
+
+spring.data.mongodb.uri: mongodb\://${mongo.user}\:${mongo.pass}@${mongo.host}\:${mongo.port}/news?authSource=admin