Comments (6)
Definite fix for 1.2, although it wouldn't be bad to make a 1.1.1 with that.
Quick logic idea:
When fetching the anime/manga list, we count how many items are returned and compare with our table row count for that type. If our number is larger, truncate the table and re-save. We do this per-type so we don't waste too much time cleaning the other type table if it's not needed. The basic idea behind all this is that the website should be the authority for data.
from atarashii.
That would work, though doing that I'm not entirely sure how we would know which entries to remove.
Actually, we can use that to determine if we need to iterate through the data to find out which entries were deleted, but that could bring its own problems (adding and deleting in the same sync would yield same count and then the delete check wouldn't trigger).
The easy way out is check every time, but that's not very efficient is it, this could be trickier than I initially thought.
from atarashii.
Just remove all entries if and only if the item count is different. AFAIK, SQLite supports "truncate", but it does support deletion without a "where" clause, so the way to truncate is:
DELETE FROM [tablename];
VACUUM;
Note that we probably don't need to vacuum, which clears the space used by the table. It's not likely to recover more than a few kilobytes if anything, outweighing the CPU time involved.
If we need to reset autoincrement or anything fancy, the table would need to be dropped and re-created.
from atarashii.
Minor correction. Only remove if the count we get from the web service is less than what we have internally.
The only case I can think where we might have an issue is where an item has been deleted and one or more are added. It would require two syncs to clear that out as our initial count would show more on the web side (thus we don't clean the table) and we save the new items, then when we sync again, we get the count difference and clean the table.
from atarashii.
Another option I thought of that is more elegant:
Add an "synced date" to each item in the table. When we sync against the web service, we put in the current time. After doing a sync, we simply find all rows that haven't been synced on this last run and delete those. Obviously, the only items that wouldn't get the updated timestamp would be ones the service didn't return - deleted items.
from atarashii.
That's brilliant, and very easily done too. That's likely what I'll go with. Thanks!
from atarashii.
Related Issues (20)
- Retrofit, apache & support library HOT 2
- AniList profile crash
- Add other title support again
- manga list not sorting
- Display broadcast on in anime detailview
- Side menu lag and performance issues HOT 1
- Minor problem with weird build numbers HOT 2
- Crash on Settings Scroll when language is "Portuguese Portugal" HOT 2
- Removed records are saved in the DB
- Cover image don't load when large version isn't available HOT 2
- Settings: Auto-synchronisation misunderstanding HOT 2
- [MAL] Display Anime/Manga tabs only if user has both lists. HOT 7
- YouTube & external links support
- Opening and ending songs HOT 2
- Open links in app HOT 4
- Tags not supported HOT 7
- Automatic profile update instead of timer? HOT 3
- More metadata on mangas HOT 1
- More search filtering HOT 5
- Archive project? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atarashii.