Skip to content

Commit

Permalink
Remove caching of getMembers()
Browse files Browse the repository at this point in the history
  • Loading branch information
dec4234 committed May 10, 2021
1 parent 46068f9 commit 7de0621
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/main/java/material/clan/Clan.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,35 @@ public Clan(long clanId, String clanName) {
}

public String getClanID() {
if(clanId == -1) {
if (clanId == -1) {
clanId = getDetail().get("groupId").getAsLong();
}
return clanId + "";
}

public String getClanName() {
if(clanName == null) {
if (clanName == null) {
getDetail().get("name").getAsString();
}
return clanName;
}

public String getClanDescription() {
if(clanDescription == null) {
if (clanDescription == null) {
clanDescription = getDetail().get("about").getAsString();
}
return clanDescription;
}

public Date getCreationDate() {
if(creationDate == null) {
if (creationDate == null) {
creationDate = StringUtils.valueOfZTime(getDetail().get("creationDate").getAsString());
}
return creationDate;
}

public int getMemberCount() {
if(memberCount == -1) {
if (memberCount == -1) {
memberCount = getDetail().get("memberCount").getAsInt();
}
return memberCount;
Expand All @@ -101,7 +101,7 @@ public boolean isPublic() {
}

public String getMotto() {
if(motto == null) {
if (motto == null) {
motto = getDetail().get("motto").getAsString();
}
return motto;
Expand Down Expand Up @@ -157,7 +157,7 @@ public List<BungieUser> getMostInactiveMembers(int numberOfResults, String... ex
List<BungieUser> sorted = new LinkedList<>();
BungieUser temp = null;

for(int i = 0; i < numberOfResults; i++) {
for (int i = 0; i < numberOfResults; i++) {
for (BungieUser bungieUser : list) {
if (temp != null) {
if (temp != bungieUser && !sorted.contains(bungieUser) && !exlcluded.contains(bungieUser.getBungieMembershipID())) {
Expand Down Expand Up @@ -200,9 +200,7 @@ public List<BungieUser> getMembers() {
List<BungieUser> source = new ArrayList<>();
List<String> stream = new ArrayList<>();

if (jj == null) {
jj = hu.urlRequestGET("https://www.bungie.net/Platform/GroupV2/" + getClanID() + "/Members/").get("Response").getAsJsonObject();
}
jj = hu.urlRequestGET("https://www.bungie.net/Platform/GroupV2/" + getClanID() + "/Members/").get("Response").getAsJsonObject();

for (JsonElement jsonElement : jj.getAsJsonArray("results")) {
stream.add(jsonElement.getAsJsonObject().getAsJsonObject("destinyUserInfo").get("membershipId").getAsString());
Expand Down Expand Up @@ -236,13 +234,7 @@ public List<BungieUser> getMembers() {
public List<BungieUser> getMembersOld() {
List<BungieUser> temp = new ArrayList<>();

if (members != null) {
return members;
}

if (jj == null) {
jj = hu.urlRequestGET("https://www.bungie.net/Platform/GroupV2/" + getClanID() + "/Members/").get("Response").getAsJsonObject();
}
jj = hu.urlRequestGET("https://www.bungie.net/Platform/GroupV2/" + getClanID() + "/Members/").get("Response").getAsJsonObject();

for (JsonElement je : jj.getAsJsonArray("results")) {
CompletableFuture<BungieUser> cf = new CompletableFuture<>();
Expand Down

0 comments on commit 7de0621

Please sign in to comment.