Commit d4a496fc authored by Christopher Bohn's avatar Christopher Bohn 🤔
Browse files

Fixed bug where only some timestamps are reported from "onecall" dataset

parent bf42ba6b
......@@ -398,20 +398,17 @@ public class OpenWeatherConnector {
* {@link List}.
* @param jsonListName the name of the JSON list containing data with timestamps
* @param timestamps the possibly-nonempty {@link List} to place the {@link Date} timestamps in
* @return the provided {@link List}, populated with the additional timestamps
*/
private List<Date> moveTimestampsFromJsonArrayToJavaList(String jsonListName, List<Date> timestamps) {
private void moveTimestampsFromJsonArrayToJavaList(String jsonListName, List<Date> timestamps) {
if (data.containsKey(jsonListName)) {
JSONArray entries = (JSONArray)data.get(jsonListName);
if (entries != null) {
timestamps = new ArrayList<>(entries.size());
for (Object entry : entries) {
long unixTime = (Long)((JSONObject)entry).get("dt");
timestamps.add(new Date(unixTime * 1000));
}
}
}
return timestamps;
}
/**
......@@ -425,7 +422,7 @@ public class OpenWeatherConnector {
Set<String> possibleListNames = Set.of("list", "minutely", "hourly", "daily");
List<Date> timestamps = new ArrayList<>();
for (String listName : possibleListNames) {
timestamps = moveTimestampsFromJsonArrayToJavaList(listName, timestamps);
moveTimestampsFromJsonArrayToJavaList(listName, timestamps);
}
timestamps.sort(null);
return List.copyOf(timestamps);
......@@ -441,7 +438,7 @@ public class OpenWeatherConnector {
public List<Date> getTimestamps(String listName) {
checkForDataReadiness(null);
List<Date> timestamps = new ArrayList<>();
timestamps = moveTimestampsFromJsonArrayToJavaList(listName, timestamps);
moveTimestampsFromJsonArrayToJavaList(listName, timestamps);
timestamps.sort(null);
return List.copyOf(timestamps);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment