This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Resolve "In der Workcloud sind in der Liste der Programmiersprache Dupikate mit Groß/Kleinschreibung"

Viewing commit ce951bea
Show latest version
1 file
+ 18
0
Compare changes
  • Side-by-side
  • Inline
@@ -305,6 +305,7 @@ public class MetaDataRepository {
}
});
reloadedCachedCompletions.values().forEach(c -> simplify(c));
cachedCompletions = reloadedCachedCompletions;
} catch (co.elastic.clients.elasticsearch._types.ElasticsearchException | ElasticsearchException | ConnectException ex) {
// this may happen mainly during testing, when
@@ -318,6 +319,23 @@ public class MetaDataRepository {
}
}
/**
* this simplifies completion lists. It combines all found entries with same
* lowercase representation, and sums them up under the most returned value.
* (e.g. Java -> 4, java -> 2, JAVA -> 1 is combined to "Java -> 7").
*
* @param entries
*/
public void simplify(Map<String, Map<String, Integer>> entries) {
entries.forEach((lowerCaseValue, upperCaseValues) -> {
final Optional<Entry<String, Integer>> max = upperCaseValues.entrySet().stream().max((e1, e2) -> e1.getValue() - e2.getValue());
max.ifPresent(maxEntry -> {
int sum = upperCaseValues.entrySet().stream().mapToInt(o -> o.getValue()).sum();
entries.put(lowerCaseValue, Collections.singletonMap(maxEntry.getKey(), sum));
});
});
}
public static String filterDateString(String sourceAsJSON) {
return sourceAsJSON.replaceAll("[+-]\\d{2}:\\d{2}", "");
}