close #2 import duplicates are detected and ignored

This commit is contained in:
2026-08-04 20:45:51 -06:00
parent 8e2211fd04
commit 856e483570
2 changed files with 38 additions and 8 deletions
+10 -3
View File
@@ -2,15 +2,16 @@
CLI tracker to prioritize your limited time by ELO ranking media. CLI tracker to prioritize your limited time by ELO ranking media.
## Initial Ideas ## Initial Ideas
- [ ] Mark books read/unread/in-progress. - [x] Mark books read/unread/in-progress.
- [x] Show top 10 / bottom 10. Show only in-progress or unread. - [x] Show top 10 / bottom 10. Show only in-progress or unread.
- [ ] Rank only in-progress or unread. - [ ] Rank only in-progress or unread.
- [x] Track books by title, author, and series. Default is to recognize "by" or "(series)" and automatically sort into relevant fields. - [x] Track books by title, author, and series. Default is to recognize "by" or "(series)" and automatically sort into relevant fields.
- [x] But also almost nothing is actually *needed*. - [x] But also almost nothing is actually *needed*.
- [x] Store progress as a numerical value? (Unread = 0, read = 1, in-progress in-between? Too easy to forget how it works?)
- [x] Store pages as an option, - [x] Store pages as an option,
- [ ] allow a weighted priority based on remaining percentage or whatever. - [x] allow a weighted priority based on remaining percentage or whatever.
- [x] Store items as an array instead of object, because that makes the JSON output more consistent -> smaller JSON commit differences. - [x] Store items as an array instead of object, because that makes the JSON output more consistent -> smaller JSON commit differences.
- [ ] I am not sure this actually helps much when EACH ITEM is still an
object. I need to make the JSON export sort its keys.
- [ ] Re-implement ELO ranking. - [ ] Re-implement ELO ranking.
- [ ] Display filter/sort options to output lists. (Focus only on top 10 items?) - [ ] Display filter/sort options to output lists. (Focus only on top 10 items?)
@@ -22,6 +23,12 @@ I accept pull requests and issues, but management of the code is handled there.
Licensing? I don't care. Do whatever you want. IP rights are stupid. Licensing? I don't care. Do whatever you want. IP rights are stupid.
## Ideas
- [ ] When importing, allow user to make a choice when duplicates are detected
instead of rejecting them automatically.
- [ ] When importing, a duplicate should still be checked for missing data, and
merge rather than ignore.
## Book Data Structure ## Book Data Structure
```json ```json
{ {
+26 -3
View File
@@ -249,14 +249,35 @@ local update_book = function(book)
return update_progress_prompt(book) return update_progress_prompt(book)
end end
local book_exists = function(data, book)
for i = 1, #data.books do
local current = data.books[i]
if not (book.title == current.title) then
break
end
if not (book.author == current.author) then
break
end
if not (book.series == current.series) then
break
end
if not (book.genre == current.genre) then
break
end
return current -- we return the object instead of true so it can be updated if desired
end
return false
end
local import_json = function(data, file_name) local import_json = function(data, file_name)
import = load_json(file_name) import = load_json(file_name)
if import.books then if import.books then
for i = 1, #import.books do for i = 1, #import.books do
-- TODO allow updating metadata instead of just ignoring
if not book_exists(data, import.books[i]) then
data.books[#data.books + 1] = import.books[i] data.books[#data.books + 1] = import.books[i]
-- TODO detect and ignore duplicates (would be better to provide user an option for what to do with duplicates) end
-- default should accept highest progress of duplicates?
end end
else -- assume we are importing from decider.lua's format else -- assume we are importing from decider.lua's format
@@ -292,9 +313,11 @@ local import_json = function(data, file_name)
end end
end end
-- TODO detect duplicates before adding them -- TODO allow updating metadata (this and the above need to be split into its own function)
if not book_exists(data, book) then
data.books[#data.books + 1] = book data.books[#data.books + 1] = book
end end
end
run() run()
end end
end end