Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
24bbf226
Commit
24bbf226
authored
Mar 14, 2021
by
alfred82santa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync reading state only for books on kobo shelves
parent
6014b04b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
kobo.py
cps/kobo.py
+30
-5
No files found.
cps/kobo.py
View file @
24bbf226
...
...
@@ -171,7 +171,7 @@ def HandleSyncRequest():
ub
.
BookShelf
.
date_added
>
sync_token
.
books_last_modified
))
.
filter
(
db
.
Data
.
format
.
in_
(
KOBO_FORMATS
))
.
order_by
(
db
.
Books
.
id
)
.
order_by
(
'last_modified'
)
.
order_by
(
ub
.
ArchivedBook
.
last_modified
)
.
join
(
ub
.
BookShelf
,
db
.
Books
.
id
==
ub
.
BookShelf
.
book_id
)
.
join
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
kobo_sync
)
...
...
@@ -253,11 +253,36 @@ def HandleSyncRequest():
books_last_id
=
-
1
# generate reading state data
changed_reading_states
=
ub
.
session
.
query
(
ub
.
KoboReadingState
)
if
only_kobo_shelves
:
changed_reading_states
=
(
changed_reading_states
.
join
(
ub
.
BookShelf
,
ub
.
KoboReadingState
.
book_id
==
ub
.
BookShelf
.
book_id
)
.
join
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
kobo_sync
,
or_
(
func
.
datetime
(
ub
.
KoboReadingState
.
last_modified
)
>
sync_token
.
reading_state_last_modified
,
ub
.
BookShelf
.
date_added
>
sync_token
.
books_last_modified
)
)
)
.
distinct
()
else
:
changed_reading_states
=
(
changed_reading_states
.
filter
(
func
.
datetime
(
ub
.
KoboReadingState
.
last_modified
)
>
sync_token
.
reading_state_last_modified
)
)
changed_reading_states
=
(
ub
.
session
.
query
(
ub
.
KoboReadingState
)
.
filter
(
and_
(
func
.
datetime
(
ub
.
KoboReadingState
.
last_modified
)
>
sync_token
.
reading_state_last_modified
,
ub
.
KoboReadingState
.
user_id
==
current_user
.
id
,
ub
.
KoboReadingState
.
book_id
.
notin_
(
reading_states_in_new_entitlements
))))
changed_reading_states
.
filter
(
and_
(
ub
.
KoboReadingState
.
user_id
==
current_user
.
id
,
ub
.
KoboReadingState
.
book_id
.
notin_
(
reading_states_in_new_entitlements
)
)
)
)
for
kobo_reading_state
in
changed_reading_states
.
all
():
book
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
kobo_reading_state
.
book_id
)
.
one_or_none
()
if
book
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment