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.id = "";
placeholder.description = "Please download Scryfall tags from the 'download' tab & reopen"; placeholder.description = "Please download Scryfall tags from the 'download' tab & reopen";
placeholder.label = "Data missing!"; 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) @DatabaseField(indexName = "tags_oracle_id_index", uniqueCombo = true)
protected String oracle_id; 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; protected Tag tag;
} }

View file

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