close #2 import duplicates are detected and ignored
This commit is contained in:
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
+28
-5
@@ -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
|
||||||
data.books[#data.books + 1] = import.books[i]
|
-- TODO allow updating metadata instead of just ignoring
|
||||||
-- TODO detect and ignore duplicates (would be better to provide user an option for what to do with duplicates)
|
if not book_exists(data, import.books[i]) then
|
||||||
-- default should accept highest progress of duplicates?
|
data.books[#data.books + 1] = import.books[i]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else -- assume we are importing from decider.lua's format
|
else -- assume we are importing from decider.lua's format
|
||||||
@@ -292,8 +313,10 @@ 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)
|
||||||
data.books[#data.books + 1] = book
|
if not book_exists(data, book) then
|
||||||
|
data.books[#data.books + 1] = book
|
||||||
|
end
|
||||||
end
|
end
|
||||||
run()
|
run()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user