-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
996833c
commit 8f77979
Showing
3 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
chat example | ||
run: | ||
python -m example.chat | ||
""" | ||
from database.database import init_db | ||
from env_wrapper import load_env | ||
from pagination.pagination import PaginationSortOptions | ||
from user.service import UserService | ||
|
||
from chat.service import ChatHistoryPaginationOptions, ChatService | ||
|
||
# setup | ||
load_env() | ||
init_db() | ||
|
||
# list chat history | ||
from_user = UserService.find_by_id(2) | ||
to_user = UserService.find_by_id(3) | ||
|
||
opts = ChatHistoryPaginationOptions() | ||
opts.page = 1 | ||
opts.limit = 20 | ||
opts.sort = PaginationSortOptions.DESC | ||
opts.order_by = "send_date" | ||
opts.search = "" | ||
|
||
opts.from_user_id = from_user.id | ||
opts.to_user_id = to_user.id | ||
|
||
|
||
chats = ChatService.list_chat_history(opts) | ||
|
||
for chat in chats: | ||
print(chat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters