Skip to content

Commit

Permalink
Stopped some error messages from appearing in GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Jul 14, 2020
1 parent 1695ab7 commit be1cbff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ public static List<FragmentedPacketGroup> mergePackets(List<? extends InstancePa
*/
@Contract(pure = true)
public static List<FragmentedPacketGroup> mergePackets(List<? extends InstancePacketGroup> instancePacketGroups, long maxTimeDistance, Long masterIdIgnoreDistance, Comparator<Integer> fragmentIdComparator){
if (instancePacketGroups.isEmpty()) {
throw new IllegalArgumentException("instancePacketGroups cannot be empty!");
}
Map<Integer, List<InstancePacketGroup>> fragmentMap = new HashMap<>();
for(InstancePacketGroup packetGroup : instancePacketGroups){ // this for loop initializes fragmentMap
final int fragmentId = packetGroup.getFragmentId();
Expand Down Expand Up @@ -192,6 +195,9 @@ private static void addToPacketGroups(
if(minTime > maxTime){
return;
}
if (fragmentIds.isEmpty()) {
throw new IllegalArgumentException("Fragment IDs is empty!");
}
int masterFragmentId = fragmentIds.get(0);
List<? extends InstancePacketGroup> masterList = requireNonNull(fragmentMap.get(masterFragmentId));
if(masterIdIgnoreDistance != null && fragmentIds.size() > 1){ // see if we need to check for gaps in the master list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package me.retrodaredevil.solarthing.solar.outback.fx.charge;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import me.retrodaredevil.solarthing.annotations.JsonExplicit;
import me.retrodaredevil.solarthing.annotations.Nullable;
import me.retrodaredevil.solarthing.packets.Packet;
import me.retrodaredevil.solarthing.solar.extra.SolarExtraPacketType;
import me.retrodaredevil.solarthing.solar.extra.SupplementarySolarExtraPacket;
import me.retrodaredevil.solarthing.solar.outback.OutbackData;
import me.retrodaredevil.solarthing.annotations.Nullable;

import me.retrodaredevil.solarthing.annotations.NotNull;

/**
* Note that data from this was never accurate because it didn't take temperature compensation into account
*/
@JsonDeserialize(as = ImmutableFXChargingPacket.class)
@JsonExplicit
public interface FXChargingPacket extends OutbackData, Packet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public SimpleQueryHandler(DefaultInstanceOptions defaultInstanceOptions, ObjectM
metaQueryHandler = new MetaQueryHandler(new StdCouchDbConnector(SolarThingConstants.CLOSED_UNIQUE_NAME, instance), metaObjectMapper);
}
public List<? extends FragmentedPacketGroup> sortPackets(List<? extends InstancePacketGroup> packets, String sourceId) {
if (packets.isEmpty()) {
return Collections.emptyList();
}
if (sourceId == null) {
return PacketGroups.mergePackets(PacketGroups.parseToInstancePacketGroups(packets, defaultInstanceOptions), 2 * 60 * 1000, 2 * 60 * 1000L);
}
Expand Down
6 changes: 3 additions & 3 deletions other/docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
* Create a calendar program to be able to view daily kWh on a calendar interface
* If we do something with a calendar, we could use Google calendar https://developers.google.com/calendar/create-events/
* Create button/widget on Grafana that sends an encrypted command to shut off the generator
* Create GraphQL query that allows someone to get dailyKWH from a large time period (many days) for
easy displaying in Grafana
* Packet for disk usage
* Make CouchDB and InfluxDB database configuration warn when setting unused values
* Make sure that the latest packet handler is really the latest. (Aux On has been frequently sent twice with the generator shutoff)
* Make sure the latest packet handler is really the latest. (Aux On has been frequently sent twice with the generator shutoff)

### Android TODO
* Notification for when FXs are in EQ, but any MX is in absorb or float
Expand Down Expand Up @@ -40,6 +38,8 @@ easy displaying in Grafana
* Store metadata
* Put this in a document named `meta` in `solarthing_closed
* Add temperature event to message program
* Create GraphQL query that allows someone to get dailyKWH from a large time period (many days) for
easy displaying in Grafana

### TODO Look into
* Look into supporting Elasticsearch, MongoDB, Graphite
Expand Down

0 comments on commit be1cbff

Please sign in to comment.