use of org.stepik.core.courseFormat.StudyStatus.UNCHECKED in project intellij-plugins by StepicOrg.
the class Node method getStatus.
@NotNull
@Override
public StudyStatus getStatus() {
if (isUnknownStatus()) {
status = UNCHECKED;
executor.execute(() -> {
StepikApiClient stepikApiClient = authAndGetStepikApiClient();
if (!isAuthenticated()) {
return;
}
Map<String, StudyNode> progressMap = new HashMap<>();
Node.this.getChildren().stream().filter(StudyNode::isUnknownStatus).forEach(child -> {
DC data = child.getData();
if (data != null) {
progressMap.put(data.getProgress(), child);
}
});
D data = Node.this.getData();
if (data != null) {
String progressId = data.getProgress();
if (progressId != null) {
progressMap.put(progressId, Node.this);
}
Set<String> progressIds = progressMap.keySet();
if (!progressIds.isEmpty()) {
int size = progressIds.size();
String[] list = progressIds.toArray(new String[size]);
int start = 0;
int end;
while (start < size) {
end = start + 20;
if (end > size) {
end = size;
}
String[] part = Arrays.copyOfRange(list, start, end);
start = end;
Progresses progresses;
try {
progresses = stepikApiClient.progresses().get().id(part).execute();
} catch (StepikClientException e) {
logger.warn(e);
return;
}
progresses.getItems().forEach(progress -> {
String id = progress.getId();
StudyNode node = progressMap.get(id);
if (progress.isPassed()) {
node.setRawStatus(SOLVED);
}
});
}
}
}
ApplicationManager.getApplication().invokeLater(() -> {
if (!project.isDisposed()) {
ProjectView.getInstance(project).refresh();
}
});
});
}
return status;
}
Aggregations