Skip to content

Commit

Permalink
feat: add feedServiceWindow to JSON report (#1852)
Browse files Browse the repository at this point in the history
added feedServiceWindow to JSON report
  • Loading branch information
qcdyx authored Sep 27, 2024
1 parent 9fe5979 commit 0975944
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public JsonReportFeedInfo(Map<String, String> feedInfo) {
feedLanguage = feedInfo.get(FeedMetadata.FEED_INFO_FEED_LANGUAGE);
feedStartDate = feedInfo.get(FeedMetadata.FEED_INFO_FEED_START_DATE);
feedEndDate = feedInfo.get(FeedMetadata.FEED_INFO_FEED_END_DATE);
feedServiceWindowStart = feedInfo.get(FeedMetadata.FEED_INFO_SERVICE_WINDOW_START);
feedServiceWindowEnd = feedInfo.get(FeedMetadata.FEED_INFO_SERVICE_WINDOW_END);
}

String publisherName;
Expand All @@ -126,6 +128,8 @@ public JsonReportFeedInfo(Map<String, String> feedInfo) {
String feedStartDate;
String feedEndDate;
String feedEmail;
String feedServiceWindowStart;
String feedServiceWindowEnd;
}

private static class JsonReportAgencyMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class FeedMetadata {
public static final String FEED_INFO_FEED_START_DATE = "Feed Start Date";
public static final String FEED_INFO_FEED_END_DATE = "Feed End Date";
public static final String FEED_INFO_SERVICE_WINDOW = "Service Window";
public static final String FEED_INFO_SERVICE_WINDOW_START = "Service Window Start";
public static final String FEED_INFO_SERVICE_WINDOW_END = "Service Window End";

private static final FluentLogger logger = FluentLogger.forEnclosingClass();

Expand Down Expand Up @@ -530,6 +532,11 @@ public void loadServiceWindow(
serviceWindow.append(latestEndDate);
feedInfo.put(FEED_INFO_SERVICE_WINDOW, serviceWindow.toString());
}
feedInfo.put(
FEED_INFO_SERVICE_WINDOW_START,
earliestStartDate == null ? "" : earliestStartDate.toString());
feedInfo.put(
FEED_INFO_SERVICE_WINDOW_END, latestEndDate == null ? "" : latestEndDate.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ private static FeedMetadata generateFeedMetaData() {
"value2",
FeedMetadata.FEED_INFO_FEED_CONTACT_EMAIL,
"me@foo.com",
FeedMetadata.FEED_INFO_SERVICE_WINDOW_START,
"2024-01-02",
FeedMetadata.FEED_INFO_SERVICE_WINDOW_END,
"2024-11-06",
"Illegal Key",
"Some Value" // Should not be present in the resulting GSON
);
Expand Down Expand Up @@ -120,7 +124,7 @@ public void withFeedMetadataWithConfigTest() throws Exception {
+ "\"htmlReportName\":\"some_html_filename\","
+ "\"countryCode\":\"GB\","
+ "\"dateForValidation\":\"2020-01-02\","
+ "\"feedInfo\":{\"publisherName\":\"value1\",\"publisherUrl\":\"value2\",\"feedEmail\":\"me@foo.com\"},"
+ "\"feedInfo\":{\"publisherName\":\"value1\",\"publisherUrl\":\"value2\",\"feedEmail\":\"me@foo.com\",\"feedServiceWindowStart\":\"2024-01-02\", \"feedServiceWindowEnd\":\"2024-11-06\"},"
+ "\"validationTimeSeconds\":100.0,"
+ "\"agencies\":["
+ "{\"name\":\"agency1\",\"url\":\"some URL 1\",\"phone\":\"phone1\",\"email\":\"email1\"},"
Expand All @@ -142,7 +146,7 @@ public void withFeedMetadataNoConfigTest() throws Exception {
"{\"validatorVersion\":\"1.0\","
+ "\"validatedAt\":\"now\","
+ "\"threads\":0,"
+ "\"feedInfo\":{\"publisherName\":\"value1\",\"publisherUrl\":\"value2\",\"feedEmail\":\"me@foo.com\"},"
+ "\"feedInfo\":{\"publisherName\":\"value1\",\"publisherUrl\":\"value2\",\"feedEmail\":\"me@foo.com\",\"feedServiceWindowStart\":\"2024-01-02\", \"feedServiceWindowEnd\":\"2024-11-06\"},"
+ "\"validationTimeSeconds\":100.0,"
+ "\"agencies\":["
+ "{\"name\":\"agency1\",\"url\":\"some URL 1\",\"phone\":\"phone1\",\"email\":\"email1\"},"
Expand Down

0 comments on commit 0975944

Please sign in to comment.