diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-17 06:32:46 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-17 06:32:46 +0300 |
commit | 5d9f1fcc26d9090e2250fc39543dbff00abf8d3a (patch) | |
tree | e0ab3246951bb1f527ebd0507e864f8f3e7ec27f /vk/utils/tracking/db | |
parent | make the status logger a database writer (diff) | |
download | vk-scripts-5d9f1fcc26d9090e2250fc39543dbff00abf8d3a.tar.gz vk-scripts-5d9f1fcc26d9090e2250fc39543dbff00abf8d3a.zip |
add basic "online periods" extraction
Diffstat (limited to 'vk/utils/tracking/db')
-rw-r--r-- | vk/utils/tracking/db/record.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vk/utils/tracking/db/record.py b/vk/utils/tracking/db/record.py index fd684cc..fd276fc 100644 --- a/vk/utils/tracking/db/record.py +++ b/vk/utils/tracking/db/record.py @@ -102,14 +102,23 @@ class Record(MutableMapping): assert False return record + def _update_last_seen_field(self, last_seen, field): + if field is LastSeenField.TIME: + last_seen[field] = self[field].dt + else: + last_seen[field] = self[field] + + def _update_user_field(self, user, field): + user[field] = self[field] + def to_user(self): user = User() last_seen = LastSeen() for field in self: if isinstance(field, LastSeenField): - last_seen[field] = self[field] + self._update_last_seen_field(last_seen, field) elif isinstance(field, UserField): - user[field] = self[field] + self._update_user_field(user, field) else: assert False if len(last_seen): |