Skip to content

Commit

Permalink
watch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Jul 10, 2020
1 parent 1fa292c commit 95d62e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions google/cloud/firestore_v1/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,11 @@ def __eq__(self, other):
return self._reference == other._reference and self._data == other._data

def __hash__(self):
seconds = self.update_time.seconds
nanos = self.update_time.nanos
# TODO(microgen): maybe add datetime_with_nanos to protoplus, revisit
# seconds = self.update_time.seconds
# nanos = self.update_time.nanos
seconds = self.update_time.second
nanos = 0
return hash(self._reference) + hash(seconds) + hash(nanos)

@property
Expand Down
9 changes: 7 additions & 2 deletions google/cloud/firestore_v1/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __init__(
ResumableBidiRpc = self.ResumableBidiRpc # FBO unit tests

self._rpc = ResumableBidiRpc(
self._api.transport.listen,
self._api._transport.listen,
should_recover=_should_recover,
should_terminate=_should_terminate,
initial_request=rpc_request,
Expand Down Expand Up @@ -261,6 +261,9 @@ def __init__(
def _get_rpc_request(self):
if self.resume_token is not None:
self._targets["resume_token"] = self.resume_token

self._targets["query"] = self._targets["query"]._pb

return firestore.ListenRequest(
database=self._firestore._database_string, add_target=self._targets
)
Expand Down Expand Up @@ -570,7 +573,9 @@ def push(self, read_time, next_resume_token):
self._snapshot_callback(
keys,
appliedChanges,
datetime.datetime.fromtimestamp(read_time.seconds, pytz.utc),
read_time
# TODO(microgen): now a datetime
# datetime.datetime.fromtimestamp(read_time.seconds, pytz.utc),
)
self.has_pushed = True

Expand Down

0 comments on commit 95d62e5

Please sign in to comment.