36 lines
876 B
Java
36 lines
876 B
Java
package xyz.etztech.serverapi.web.api;
|
|
|
|
import com.expediagroup.graphql.annotations.GraphQLDescription;
|
|
import com.expediagroup.graphql.annotations.GraphQLName;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
@GraphQLName("TPS")
|
|
@GraphQLDescription("TPS GraphQL")
|
|
public class TPSAPI {
|
|
private final LinkedList<Float> history;
|
|
|
|
public TPSAPI(LinkedList<Float> history) {
|
|
this.history = history;
|
|
}
|
|
|
|
@GraphQLName("history")
|
|
public LinkedList<Float> getHistory() {
|
|
return history;
|
|
}
|
|
|
|
@JsonProperty("average")
|
|
@GraphQLName("average")
|
|
public float getAverageTPS() {
|
|
float avg = 0;
|
|
if (history.size() == 0) return avg;
|
|
for (Float f : history) {
|
|
if (f != null) {
|
|
avg += f;
|
|
}
|
|
}
|
|
return avg / history.size();
|
|
}
|
|
}
|