Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
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
Oleksandr Barabash
cake-bot
Commits
75584bf8
Commit
75584bf8
authored
Dec 06, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no items issue fixed
parent
9b9c1e6f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
23 deletions
+12
-23
camel_case_mixin.py
entities/json/camel_case_mixin.py
+0
-4
cosmos_client.py
utils/cosmos_client.py
+12
-19
No files found.
entities/json/camel_case_mixin.py
View file @
75584bf8
...
...
@@ -23,15 +23,11 @@ class CamelCaseMixin:
@pre_load
def
to_snake_case
(
self
,
data
,
**
_kwargs
):
""" to snake case pre load method """
if
isinstance
(
data
,
list
):
return
[
self
.
to_snake_case
(
item
)
for
item
in
data
]
return
{
snakecase
(
key
):
value
for
key
,
value
in
data
.
items
()}
@post_dump
def
to_camel_case
(
self
,
data
,
**
_kwargs
):
""" to camel case post load method """
if
isinstance
(
data
,
list
):
return
[
self
.
to_camel_case
(
item
)
for
item
in
data
]
return
{
camelcase
(
key
):
value
for
key
,
value
in
data
.
items
()}
@classmethod
...
...
utils/cosmos_client.py
View file @
75584bf8
...
...
@@ -115,6 +115,16 @@ class CosmosClient:
return
await
self
.
execute_blocking
(
bl
)
def
get_next_page_bl
(
self
,
pager
):
""" Get Next page items Blocking """
try
:
# todo(s1z): why do we get [0], as MS does? This is bad!!!
return
list
(
pager
.
next
())[
0
]
except
StopIteration
:
Log
.
e
(
TAG
,
"get_next_page_bl:: no items found, returning '[]'"
,
exc_info
=
sys
.
exc_info
())
return
[]
async
def
get_initiation_items
(
self
,
notification_id
,
token
=
None
)
->
Tuple
[
List
[
Initiation
],
str
]:
""" Get Initiation Items """
...
...
@@ -123,8 +133,6 @@ class CosmosClient:
def
bl
()
->
Tuple
[
List
[
Dict
[
str
,
Any
]],
str
]:
""" Potential blocking code """
# noinspection SqlDialectInspection,SqlNoDataSourceInspection
items
=
[]
continuation_token
=
None
Log
.
d
(
TAG
,
"get_initiation_items:: init query"
)
query_iterable
=
container
.
query_items
(
query
=
"SELECT * FROM r "
...
...
@@ -136,23 +144,8 @@ class CosmosClient:
partition_key
=
notification_id
,
max_item_count
=
1
)
Log
.
d
(
TAG
,
"get_initiation_items:: getting pager"
)
if
token
is
not
None
:
pager
=
query_iterable
.
by_page
(
token
)
else
:
pager
=
query_iterable
.
by_page
()
Log
.
d
(
TAG
,
"get_initiation_items:: getting items"
)
try
:
new_items
=
list
(
pager
.
next
())[
0
]
except
Exception
:
new_items
=
[]
Log
.
e
(
TAG
,
"get_initiation_items:: oops, error"
,
exc_info
=
sys
.
exc_info
())
Log
.
d
(
TAG
,
"get_initiation_items:: adding items"
)
items
.
append
(
new_items
)
Log
.
d
(
TAG
,
"get_initiation_items:: getting token"
)
pager
=
query_iterable
.
by_page
(
token
)
items
=
self
.
get_next_page
(
pager
)
continuation_token
=
pager
.
continuation_token
return
(
...
...
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