Skip to content

Commit

Permalink
Added some GraphQL descriptions, from is optional in queryFullDay
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Feb 28, 2024
1 parent 3712cbb commit d4d365e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.nio.file.Path;

import static java.util.Objects.requireNonNull;

@JsonTypeName("w1-temperature")
public class W1TemperatureDataRequester implements DataRequester {
private final Path directory;
Expand All @@ -17,9 +19,8 @@ public W1TemperatureDataRequester(
@JsonProperty(value = "directory", required = true) Path directory,
@JsonProperty(value = "data_id", required = true) int dataId
) {
this.directory = directory;
this.directory = requireNonNull(directory);
this.dataId = dataId;
// TODO add required property
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public final class SchemaConstants {
private SchemaConstants() { throw new UnsupportedOperationException(); }

public static final String DESCRIPTION_INCLUDE_UNKNOWN_CHANGE = "Set to true to include ChangePackets with unknown values. Default false.";
public static final String DESCRIPTION_FROM = "The minimum time in milliseconds since the epoch to get data from";
public static final String DESCRIPTION_TO = "The maximum time in milliseconds since the epoch to get data from";
public static final String DESCRIPTION_FROM = "The minimum time in milliseconds since the epoch to get data from.";
public static final String DESCRIPTION_TO = "The maximum time in milliseconds since the epoch to get data from.";
public static final String DESCRIPTION_OPTIONAL_SOURCE = "The Source ID to include packets from, or null to include packets from multiple sources.";
public static final String DESCRIPTION_REQUIRED_SOURCE = "The Source ID to include packets from";
public static final String DESCRIPTION_REQUIRED_SOURCE = "The Source ID to include packets from.";
public static final String DESCRIPTION_FRAGMENT_ID = "The fragment ID to include data from.";

}
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,14 @@ public CacheSolarThingFullDayStatusQuery(List<IdentificationCacheDataPacket<Char
}
}

@GraphQLQuery
@GraphQLQuery(description = "Queries each day present in the from..to time range. Optionally leave from as null to guarantee a query for a single day only.")
public SolarThingFullDayStatusQuery queryFullDay(
@GraphQLArgument(name = "from", description = DESCRIPTION_FROM) long from, @GraphQLArgument(name = "to", description = DESCRIPTION_TO) long to,
@GraphQLArgument(name = "from", description = "The epoch millis value that will be used to determine the starting day. Set to null to guarantee a query of a single day.") @Nullable Long from,
@GraphQLArgument(name = "to", description = "The epoch millis value that will be used to determine the ending day.") long to,
@GraphQLArgument(name = "sourceId", description = DESCRIPTION_OPTIONAL_SOURCE) @Nullable String sourceId,
@GraphQLArgument(name = "useCache", defaultValue = "false") boolean useCache){

LocalDate fromDate = Instant.ofEpochMilli(from).atZone(zoneId).toLocalDate();
LocalDate fromDate = Instant.ofEpochMilli(from == null ? to : from).atZone(zoneId).toLocalDate();
LocalDate toDate = Instant.ofEpochMilli(to).atZone(zoneId).toLocalDate();
long queryStart = fromDate.atStartOfDay(zoneId).toInstant().toEpochMilli();
long queryEnd = toDate.plusDays(1).atStartOfDay(zoneId).toInstant().toEpochMilli() - 1;
Expand Down

0 comments on commit d4d365e

Please sign in to comment.