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
7ab19445
Commit
7ab19445
authored
Sep 14, 2021
by
Pavel Kuzmenko
Browse files
Merge branch 'alesh/43/refactor-mirror-update' into 'master'
refactor: fix mirror issue on client update See merge request
!173
parents
9d7b04e6
f1f1b08c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/mongodb_mirror/mirror.py
View file @
7ab19445
...
...
@@ -89,7 +89,7 @@ class MongoDBMirror:
op
=
entry
[
'op'
]
data
=
entry
[
'o'
]
ts
=
[
entry
[
'ts'
].
time
,
entry
[
'ts'
].
inc
]
collection
=
client
.
namespace
.
split
(
'.'
)
[
-
1
]
db
,
collection
=
client
.
namespace
.
split
(
'.'
)
try
:
if
op
==
MongoOperation
.
NOOP
and
not
entry
[
'ns'
]:
data
=
self
.
_serialize_data
(
data
)
...
...
@@ -101,16 +101,14 @@ class MongoDBMirror:
await
client
.
upsert
(
ts
,
data
)
elif
op
==
MongoOperation
.
UPDATE
:
if
'$v'
in
data
:
if
_set
:
=
data
.
get
(
'$set'
):
data
[
'$set'
]
=
self
.
_serialize_data
(
_set
)
if
_unset
:
=
data
.
get
(
'$unset'
):
data
[
'$unset'
]
=
self
.
_serialize_data
(
_unset
)
data
.
update
(
entry
[
'o2'
])
data
=
self
.
_serialize_data
(
data
)
await
client
.
update
(
ts
,
data
)
else
:
data
=
self
.
_serialize_document
(
data
,
collection
)
await
client
.
upsert
(
ts
,
data
)
data
=
await
self
.
_mongo
[
db
][
collection
].
find_one
(
entry
[
'o2'
],
sort
=
[(
'dateModified'
,
1
)]
)
if
data
is
None
:
LOG
.
warning
(
f
'Document not found:
{
collection
}
with
{
entry
[
"o2"
][
"_id"
]
}
'
)
continue
data
=
self
.
_serialize_document
(
data
,
collection
)
await
client
.
upsert
(
ts
,
data
)
elif
op
==
MongoOperation
.
DELETE
:
data
=
self
.
_serialize_data
(
data
)
await
client
.
delete
(
ts
,
data
)
...
...
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