aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/vk/utils/tracking/db/record.py
blob: 0a1a68735f07717cc7e6205bd13e84b5f421df21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com>
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.

from collections import OrderedDict
from datetime import datetime

from vk.user import Field

class Record:
    _FIELDS = (
        Field.UID,
        Field.FIRST_NAME,
        Field.LAST_NAME,
        Field.SCREEN_NAME,
        Field.ONLINE,
        Field.LAST_SEEN,
    )

    def __init__(self, user):
        self._fields = OrderedDict()
        for field in self._FIELDS:
            self._fields[field] = user[field]
        self._timestamp = datetime.utcnow().replace(microsecond=0)

    def to_list(self):
        return [self._timestamp.isoformat()] + list(self._fields.values())