fix index + update alert
All checks were successful
/ build_release (push) Successful in 10m33s

This commit is contained in:
Failure 2025-08-15 03:33:34 -07:00
parent 8926bcf5c2
commit d73dbfba11
3 changed files with 24 additions and 23 deletions

View file

@ -46,7 +46,12 @@ public class TaggerModel extends AbstractTableModel {
placeholder.id = "";
placeholder.description = "Please download Scryfall tags from the 'download' tab & reopen";
placeholder.label = "Data missing!";
view.add(placeholder);
Tag placeholder2 = new Tag();
placeholder2.id = "";
placeholder2.description = "You may need do a Scryfall download to associate IDs";
placeholder2.label = "Also!";
view.add(placeholder2);
}
}

View file

@ -12,7 +12,7 @@ public class TagRelation {
@DatabaseField(indexName = "tags_oracle_id_index", uniqueCombo = true)
protected String oracle_id;
@DatabaseField(indexName = "tags_tag_id_index", foreign = true, columnName = "tag_id")
@DatabaseField(indexName = "tags_tag_id_index", foreign = true, columnName = "tag_id", uniqueCombo = true)
protected Tag tag;
}

View file

@ -32,8 +32,7 @@ public enum TagRepository {
private static final int MAX_DATABASE_FIXES = 10;
private static final String VERSION_ENTITY_NAME = "tags";
private static final long TAG_VERSION = 2; // raise this if db structure was changed
private static final long TAG_RELATION_VERSION = 2; // raise this if new cards were added to the server
private static final long TAG_VERSION = 3; // raise this if db structure was changed
private Dao<Tag, Object> tagsDao;
private Dao<TagRelation, Object> tagRelationDao;
@ -99,34 +98,31 @@ public enum TagRepository {
}
try {
tagsDao.createOrUpdate(tag);
// clear out old ones
DeleteBuilder<TagRelation, Object> cleanser = tagRelationDao.deleteBuilder();
cleanser.where().eq("tag_id", tag);
cleanser.delete();
tagRelationDao.callBatchTasks(() -> {
// only add new cards (no updates)
logger.info("DB: refreshing tag " + tag.label);
// clear out old ones
DeleteBuilder<TagRelation, Object> cleanser = tagRelationDao.deleteBuilder();
cleanser.where().eq("tag_id", tag.id);
cleanser.delete();
try {
for (String oracleId : oracleIds) {
TagRelation relation = new TagRelation();
relation.oracle_id = oracleId;
relation.tag = tag;
try {
tagRelationDao.create(relation);
}
} catch (SQLException e) {
Logger.getLogger(TagRepository.class).error("Error adding tags to DB - " + e, e);
e.printStackTrace();
}
}
return null;
});
} catch (Exception e) {
e.printStackTrace();
}
try {
} catch (Exception ex) {
//
}
}