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;
public enum EdgeDomainIndexingState {
ACTIVE(0),
EXHAUSTED(1),
SPECIAL(2),
SOCIAL_MEDIA(3),
BLOCKED(-1),
REDIR(-2),
ERROR(-3),
UNKNOWN(-100);
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;
}
ACTIVE,
EXHAUSTED,
SPECIAL,
SOCIAL_MEDIA,
BLOCKED,
REDIR,
ERROR,
UNKNOWN
}

View File

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