Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
prozorro-sale
Mirror
Commits
95a53e48
Commit
95a53e48
authored
Nov 19, 2021
by
mashony
Browse files
fix: change timestamp usage while caching serialized data
parent
833c511d
Changes
3
Hide whitespace changes
Inline
Side-by-side
.dockerignore
View file @
95a53e48
...
...
@@ -81,4 +81,6 @@ venv/
*.swp
*/*.swp
*/*/*.swp
*/*/*/*.swp
\ No newline at end of file
*/*/*/*.swp
**/*.db
.gitignore
View file @
95a53e48
...
...
@@ -31,4 +31,6 @@ MANIFEST
__pycache__
.coverage*
cover-html
specs*
\ No newline at end of file
specs*
**/*.db
src/mongodb_mirror/mirror.py
View file @
95a53e48
...
...
@@ -104,7 +104,7 @@ class MongoDBMirror:
elif
entry
[
'ns'
]
!=
client
.
namespace
:
continue
elif
op
==
MongoOperation
.
INSERT
:
data
=
await
self
.
_get_serialized_document
(
data
,
collection
,
timestamp
)
data
=
await
self
.
_get_serialized_document
(
data
,
collection
,
entry
[
'ts'
]
)
await
client
.
upsert
(
ts
,
data
)
elif
op
==
MongoOperation
.
UPDATE
:
if
'$v'
in
data
:
...
...
@@ -114,7 +114,7 @@ class MongoDBMirror:
if
data
is
None
:
LOG
.
warning
(
f
'Document not found:
{
collection
}
with
{
entry
[
"o2"
][
"_id"
]
}
'
)
continue
data
=
await
self
.
_get_serialized_document
(
data
,
collection
,
timestamp
)
data
=
await
self
.
_get_serialized_document
(
data
,
collection
,
entry
[
'ts'
]
)
await
client
.
upsert
(
ts
,
data
)
elif
op
==
MongoOperation
.
DELETE
:
data
=
self
.
_serialize_data
(
data
)
...
...
@@ -153,7 +153,7 @@ class MongoDBMirror:
async
def
_get_serialized_document
(
self
,
data
,
collection
,
timestamp
):
_obj_id
=
data
.
get
(
'_id'
,
''
)
cache_key
=
f
"
{
timestamp
.
time
}
_
{
_obj_id
}
"
cache_key
=
f
"
{
timestamp
.
time
}
_
{
timestamp
.
inc
}
_
{
_obj_id
}
"
loop
=
asyncio
.
get_running_loop
()
try
:
...
...
Write
Preview
Supports
Markdown
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