Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 53286ee

Browse files
committedJan 28, 2019
Add support to search usernames
1 parent f8a1b38 commit 53286ee

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed
 

‎CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# v2.12.1
8+
9+
### Changed
10+
11+
- `logs search` now also searches usernames present in thread logs.
12+
713
# v2.12.0
814

915
### Important
@@ -13,6 +19,7 @@ In the future, the Modmail API (https://modmail.tk) will be deprecated. This is
1319
### Changed
1420
- A lot of painful code cleanup, which is good for us (the devs), but shouldn't affect you.
1521
- The appearance of the `logs` command. Should be clearer with better info now.
22+
- Bot owners get access to all commands regardless of server permissions.
1623

1724
### Added
1825

‎bot.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.12.0'
25+
__version__ = '2.12.1'
2626

2727
import asyncio
2828
from datetime import datetime
@@ -259,10 +259,25 @@ async def on_connect(self):
259259
self._connected.set()
260260

261261
async def setup_indexes(self):
262+
"""Setup text indexes so we can use the $search operator"""
262263
coll = self.db.logs
263-
if 'messages.content_text' not in await coll.index_information():
264-
print('Creating "text" index for "messages.content"')
265-
await coll.create_index([('messages.content', 'text')])
264+
index_name = 'messages.content_text_messages.author.name_text'
265+
266+
index_info = await coll.index_information()
267+
268+
# Backwards compatibility
269+
old_index = 'messages.content_text'
270+
if old_index in index_info:
271+
print('Dropping old index:', old_index)
272+
await coll.drop_index(old_index)
273+
274+
if index_name not in index_info:
275+
print('Creating "text" index for logs collection.')
276+
print('Name:', index_name)
277+
await coll.create_index([
278+
('messages.content', 'text'),
279+
('messages.author.name', 'text')
280+
])
266281

267282
async def on_ready(self):
268283
"""Bot startup, sets uptime."""

0 commit comments

Comments
 (0)
Please sign in to comment.