Skip to content

Commit da19552

Browse files
committed
update find_all
1 parent 6485ab2 commit da19552

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

src/wechaty/user/contact.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -251,33 +251,13 @@ async def find_all(cls: Type[Contact],
251251
"""
252252
log.info('find_all() <%s, %s>', cls, query)
253253

254-
# 0. load from local cache file
255-
if config.cache_contacts and os.path.exists(config.cache_contact_path):
256-
contact_payloads = load_pickle_data(config.cache_contact_path)
257-
assert isinstance(contact_payloads, list)
258-
assert isinstance(contact_payloads[0], ContactPayload)
259-
260-
contact_payloads: List[ContactPayload] = contact_payloads
261-
contacts = []
262-
for contact_payload in contact_payloads:
263-
contact = cls.load(contact_payload.id)
264-
265-
# type: ignore
266-
contact._payload = contact_payload
267-
contacts.append(contact)
268-
return contacts
269-
270254
# 1. load contacts with concurrent tasks
271255
contact_ids: List[str] = await cls.get_puppet().contact_list()
272256

273257
contacts: List[Contact] = [cls.load(contact_id) for contact_id in contact_ids]
274258
tasks: List[Task] = [asyncio.create_task(contact.ready()) for contact in contacts]
275259
await gather_with_concurrency(PARALLEL_TASK_NUM, tasks)
276260

277-
if config.cache_contacts:
278-
contact_payloads = [contact.payload for contact in contacts if contact.payload is not None]
279-
save_pickle_data(contact_payloads, config.cache_contact_path)
280-
281261
# 2. filter contacts
282262
if not query:
283263
return contacts

src/wechaty/user/room.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -225,32 +225,12 @@ async def find_all(cls,
225225
"""
226226
log.info('Room find_all <%s>', query)
227227

228-
# 0. load from local cache file
229-
if config.cache_rooms and os.path.exists(config.cache_room_path):
230-
room_payloads = load_pickle_data(config.cache_room_path)
231-
assert isinstance(room_payloads, list)
232-
assert isinstance(room_payloads[0], RoomPayload)
233-
234-
room_payloads: List[RoomPayload] = room_payloads
235-
rooms = []
236-
for room_payload in room_payloads:
237-
room = cls.load(room_payload.id)
238-
239-
# type: ignore
240-
room._payload = room_payload
241-
rooms.append(room)
242-
else:
243-
244-
# 1. load rooms with concurrent tasks
245-
room_ids = await cls.get_puppet().room_search()
246-
rooms: List[Room] = [cls.load(room_id) for room_id in room_ids]
247-
tasks: List[Task] = [asyncio.create_task(room.ready()) for room in rooms]
248-
await gather_with_concurrency(PARALLEL_TASK_NUM, tasks)
228+
# 1. load rooms with concurrent tasks
229+
room_ids = await cls.get_puppet().room_search()
230+
rooms: List[Room] = [cls.load(room_id) for room_id in room_ids]
231+
tasks: List[Task] = [asyncio.create_task(room.ready()) for room in rooms]
232+
await gather_with_concurrency(PARALLEL_TASK_NUM, tasks)
249233

250-
if config.cache_rooms:
251-
room_payloads = [room.payload for room in rooms if room.payload is not None]
252-
save_pickle_data(room_payloads, config.cache_contact_path)
253-
254234
# 2. filter the rooms
255235
if not query:
256236
return rooms

0 commit comments

Comments
 (0)