poriting to noat.cards

This commit is contained in:
Vu
2021-03-14 17:08:05 +07:00
parent 6984b4e956
commit f4af06bdff
48 changed files with 3545 additions and 3384 deletions

View File

@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin) . Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer) ."
]
},
{
@@ -67,21 +67,21 @@
"from abc import ABCMeta\n",
"\n",
"\n",
"class UserService(object):\n",
"class UserService(object) :\n",
"\n",
" def __init__(self):\n",
" def __init__(self) :\n",
" self.users_by_id = {} # key: user id, value: User\n",
"\n",
" def add_user(self, user_id, name, pass_hash): # ...\n",
" def remove_user(self, user_id): # ...\n",
" def add_friend_request(self, from_user_id, to_user_id): # ...\n",
" def approve_friend_request(self, from_user_id, to_user_id): # ...\n",
" def reject_friend_request(self, from_user_id, to_user_id): # ...\n",
" def add_user(self, user_id, name, pass_hash) : # ...\n",
" def remove_user(self, user_id) : # ...\n",
" def add_friend_request(self, from_user_id, to_user_id) : # ...\n",
" def approve_friend_request(self, from_user_id, to_user_id) : # ...\n",
" def reject_friend_request(self, from_user_id, to_user_id) : # ...\n",
"\n",
"\n",
"class User(object):\n",
"class User(object) :\n",
"\n",
" def __init__(self, user_id, name, pass_hash):\n",
" def __init__(self, user_id, name, pass_hash) :\n",
" self.user_id = user_id\n",
" self.name = name\n",
" self.pass_hash = pass_hash\n",
@@ -91,54 +91,54 @@
" self.received_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest\n",
" self.sent_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest\n",
"\n",
" def message_user(self, friend_id, message): # ...\n",
" def message_group(self, group_id, message): # ...\n",
" def send_friend_request(self, friend_id): # ...\n",
" def receive_friend_request(self, friend_id): # ...\n",
" def approve_friend_request(self, friend_id): # ...\n",
" def reject_friend_request(self, friend_id): # ...\n",
" def message_user(self, friend_id, message) : # ...\n",
" def message_group(self, group_id, message) : # ...\n",
" def send_friend_request(self, friend_id) : # ...\n",
" def receive_friend_request(self, friend_id) : # ...\n",
" def approve_friend_request(self, friend_id) : # ...\n",
" def reject_friend_request(self, friend_id) : # ...\n",
"\n",
"\n",
"class Chat(metaclass=ABCMeta):\n",
"class Chat(metaclass=ABCMeta) :\n",
"\n",
" def __init__(self, chat_id):\n",
" def __init__(self, chat_id) :\n",
" self.chat_id = chat_id\n",
" self.users = []\n",
" self.messages = []\n",
"\n",
"\n",
"class PrivateChat(Chat):\n",
"class PrivateChat(Chat) :\n",
"\n",
" def __init__(self, first_user, second_user):\n",
" super(PrivateChat, self).__init__()\n",
" self.users.append(first_user)\n",
" self.users.append(second_user)\n",
" def __init__(self, first_user, second_user) :\n",
" super(PrivateChat, self) .__init__() \n",
" self.users.append(first_user) \n",
" self.users.append(second_user) \n",
"\n",
"\n",
"class GroupChat(Chat):\n",
"class GroupChat(Chat) :\n",
"\n",
" def add_user(self, user): # ...\n",
" def remove_user(self, user): # ... \n",
" def add_user(self, user) : # ...\n",
" def remove_user(self, user) : # ... \n",
"\n",
"\n",
"class Message(object):\n",
"class Message(object) :\n",
"\n",
" def __init__(self, message_id, message, timestamp):\n",
" def __init__(self, message_id, message, timestamp) :\n",
" self.message_id = message_id\n",
" self.message = message\n",
" self.timestamp = timestamp\n",
"\n",
"\n",
"class AddRequest(object):\n",
"class AddRequest(object) :\n",
"\n",
" def __init__(self, from_user_id, to_user_id, request_status, timestamp):\n",
" def __init__(self, from_user_id, to_user_id, request_status, timestamp) :\n",
" self.from_user_id = from_user_id\n",
" self.to_user_id = to_user_id\n",
" self.request_status = request_status\n",
" self.timestamp = timestamp\n",
"\n",
"\n",
"class RequestStatus(Enum):\n",
"class RequestStatus(Enum) :\n",
"\n",
" UNREAD = 0\n",
" READ = 1\n",

View File

@@ -2,30 +2,30 @@ from abc import ABCMeta
from enum import Enum
class UserService(object):
class UserService(object) :
def __init__(self):
def __init__(self) :
self.users_by_id = {} # key: user id, value: User
def add_user(self, user_id, name, pass_hash):
def add_user(self, user_id, name, pass_hash) :
pass
def remove_user(self, user_id):
def remove_user(self, user_id) :
pass
def add_friend_request(self, from_user_id, to_user_id):
def add_friend_request(self, from_user_id, to_user_id) :
pass
def approve_friend_request(self, from_user_id, to_user_id):
def approve_friend_request(self, from_user_id, to_user_id) :
pass
def reject_friend_request(self, from_user_id, to_user_id):
def reject_friend_request(self, from_user_id, to_user_id) :
pass
class User(object):
class User(object) :
def __init__(self, user_id, name, pass_hash):
def __init__(self, user_id, name, pass_hash) :
self.user_id = user_id
self.name = name
self.pass_hash = pass_hash
@@ -35,68 +35,68 @@ class User(object):
self.received_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest
self.sent_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest
def message_user(self, friend_id, message):
def message_user(self, friend_id, message) :
pass
def message_group(self, group_id, message):
def message_group(self, group_id, message) :
pass
def send_friend_request(self, friend_id):
def send_friend_request(self, friend_id) :
pass
def receive_friend_request(self, friend_id):
def receive_friend_request(self, friend_id) :
pass
def approve_friend_request(self, friend_id):
def approve_friend_request(self, friend_id) :
pass
def reject_friend_request(self, friend_id):
def reject_friend_request(self, friend_id) :
pass
class Chat(metaclass=ABCMeta):
class Chat(metaclass=ABCMeta) :
def __init__(self, chat_id):
def __init__(self, chat_id) :
self.chat_id = chat_id
self.users = []
self.messages = []
class PrivateChat(Chat):
class PrivateChat(Chat) :
def __init__(self, first_user, second_user):
super(PrivateChat, self).__init__()
self.users.append(first_user)
self.users.append(second_user)
def __init__(self, first_user, second_user) :
super(PrivateChat, self) .__init__()
self.users.append(first_user)
self.users.append(second_user)
class GroupChat(Chat):
class GroupChat(Chat) :
def add_user(self, user):
def add_user(self, user) :
pass
def remove_user(self, user):
def remove_user(self, user) :
pass
class Message(object):
class Message(object) :
def __init__(self, message_id, message, timestamp):
def __init__(self, message_id, message, timestamp) :
self.message_id = message_id
self.message = message
self.timestamp = timestamp
class AddRequest(object):
class AddRequest(object) :
def __init__(self, from_user_id, to_user_id, request_status, timestamp):
def __init__(self, from_user_id, to_user_id, request_status, timestamp) :
self.from_user_id = from_user_id
self.to_user_id = to_user_id
self.request_status = request_status
self.timestamp = timestamp
class RequestStatus(Enum):
class RequestStatus(Enum) :
UNREAD = 0
READ = 1