Fixed conversion bug SQL->EdgeDomainIndexingState

This commit is contained in:
vlofgren 2022-06-08 16:52:33 +02:00
parent 5e472fe121
commit 2faaed3393
2 changed files with 9 additions and 24 deletions

View File

@ -1,27 +1,12 @@
package nu.marginalia.wmsa.edge.model.crawl; package nu.marginalia.wmsa.edge.model.crawl;
public enum EdgeDomainIndexingState { public enum EdgeDomainIndexingState {
ACTIVE(0), ACTIVE,
EXHAUSTED(1), EXHAUSTED,
SPECIAL(2), SPECIAL,
SOCIAL_MEDIA(3), SOCIAL_MEDIA,
BLOCKED(-1), BLOCKED,
REDIR(-2), REDIR,
ERROR(-3), ERROR,
UNKNOWN(-100); UNKNOWN
public final int code;
EdgeDomainIndexingState(int code) {
this.code = code;
}
public static EdgeDomainIndexingState fromCode(int code) {
for (var state : values()) {
if (state.code == code) {
return state;
}
}
return UNKNOWN;
}
} }

View File

@ -203,7 +203,7 @@ public class DomainInformationService {
stmt.setInt(1, domainId.getId()); stmt.setInt(1, domainId.getId());
var rsp = stmt.executeQuery(); var rsp = stmt.executeQuery();
if (rsp.next()) { if (rsp.next()) {
return EdgeDomainIndexingState.fromCode(rsp.getInt(1)); return EdgeDomainIndexingState.valueOf(rsp.getString(1));
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.error("DB error", ex); logger.error("DB error", ex);