Skip to content

Instantly share code, notes, and snippets.

@fge
Created March 5, 2015 16:15
Show Gist options
  • Select an option

  • Save fge/06f05266d0de4d99c5a0 to your computer and use it in GitHub Desktop.

Select an option

Save fge/06f05266d0de4d99c5a0 to your computer and use it in GitHub Desktop.
public MatchesData getMatchesData()
{
final Field<Integer> emptyMatches = DSL.decode()
.when(EMPTY_MATCHES_CONDITION, 1).otherwise(0);
final Field<Integer> nonEmptyMatches = DSL.decode()
.when(NONEMPTY_MATCHES_CONDITION, 1).otherwise(0);
final Field<Integer> failedMatches = DSL.decode()
.when(FAILED_MATCHES_CONDITION, 1).otherwise(0);
return jooq.select(MATCHERS.NAME, MATCHERS.MATCHER_TYPE,
MATCHERS.CLASS_NAME,
DSL.sum(emptyMatches).as("emptyMatches"),
DSL.sum(nonEmptyMatches).as("nonEmptyMatches"),
DSL.sum(failedMatches).as("failedMatches"))
.from(MATCHERS, NODES)
.where(MATCHERS.ID.eq(NODES.MATCHER_ID))
.groupBy(MATCHERS.NAME, MATCHERS.MATCHER_TYPE, MATCHERS.CLASS_NAME)
.fetch().stream()
.map(MATCH_STATISTICS_MAPPER::map)
.collect(MatchesData.asCollector());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment