return mapper(session).selectAllEnabled(properties, new RowBounds(searchOptions.getOffset(), searchOptions.getLimit()));
}
+ public int countEnabled(DbSession session, @Nullable Boolean isCustom) {
+ return mapper(session).countEnabled(isCustom);
+ }
+
public void insert(DbSession session, MetricDto dto) {
mapper(session).insert(dto);
}
});
}
- public int countCustom(DbSession session) {
- return mapper(session).countCustom();
- }
-
public void update(DbSession session, MetricDto metric) {
mapper(session).update(metric);
}
DbSession dbSession = dbClient.openSession(false);
try {
List<MetricDto> metrics = dbClient.metricDao().selectEnabled(dbSession, isCustom, searchOptions);
- int nbMetrics = dbClient.metricDao().countCustom(dbSession);
+ int nbMetrics = dbClient.metricDao().countEnabled(dbSession, isCustom);
JsonWriter json = response.newJsonWriter();
json.beginObject();
Set<String> desiredFields = desiredFields(request.paramAsStrings(Param.FIELDS));
import java.util.List;
import java.util.Map;
+import javax.annotation.Nullable;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
void disable(@Param("ids") List<Integer> ids);
- int countCustom();
+ int countEnabled(@Param("isCustom") @Nullable Boolean isCustom);
void update(MetricDto metric);
</where>
ORDER BY UPPER(m.short_name), m.short_name
</select>
- <select id="countCustom" resultType="Integer">
+ <select id="countEnabled" resultType="Integer">
SELECT COUNT(*)
FROM metrics m
<where>
AND m.enabled=${_true}
- AND m.user_managed=${_true}
+ <if test="isCustom!=null">
+ <if test="isCustom.equals(true)">
+ AND m.user_managed=${_true}
+ </if>
+ <if test="isCustom.equals(false)">
+ AND m.user_managed=${_false}
+ </if>
+ </if>
</where>
</select>