status-go/protocol/communities
Pascal Precht 0ccdec2985 feat(CommunitiesManager): introduce `CreateHistoryArchiveTorrentFromMessages` API
Prior to this commit we had a `CreateHistoryArchiveTorrent()` API which
takes a `startDate`, an `endDate` and a `partition` to create a bunch of
message archives, given a certain time range.

The function expects the messages to live in the database, which means,
all messages that need to be archived have to be saved there at some
point.

This turns out to be an issue when importing communities from third
party services, where, sometimes, there are several thousands of messages
including attachment payloads, that have to be save to the database
first.

There are only two options to get the messages into the database:

1. Make one write operation with all messages - this slow, takes a long
   time and blocks the database until done
2. Create message chunks and perform multiple write operations - this is
   also slow, takes long but makes the database a bit more responsive as
   it's many smaller operations instead of one big one

Option 2) turned out to not be super feasible either as sometimes,
inserting even a single such message can take up to 10 seconds
(depending on payload)

Which brings me to the third option.

**A third option** is to not store those imported messages as waku
message into the database, just to later query them again to create the
archives, but instead create the archives right away from all the
messages that have been loaded into memory.

This is significantly faster and doesn't block the database.

To make this possible, this commit introduces
a `CreateHistoryArchiveTorrentFromMessages()` API, and
a `CreateHistoryArchiveTorrentFromDB()` API which can be used for
different use cases.
2022-10-24 13:28:55 +02:00
..
migrations Handle organisation membership requests 2020-12-23 17:20:55 +01:00
adaptors.go feat: sync `CommunitySettings` across paired devices 2022-06-16 12:45:05 +02:00
community.go fix: community encryption was not being marshalled 2022-10-10 13:11:10 +02:00
community_categories.go feat: Add mute category methods (#2736) 2022-07-06 19:16:19 +03:00
community_categories_test.go Validate no duplicated community chat names 2021-06-03 13:27:49 +02:00
community_test.go fix: remove ourselves from members when leaving community 2022-09-21 08:35:52 +02:00
errors.go feat: introduce and distribute RequestToLeave community 2022-08-26 11:25:33 +02:00
manager.go feat(CommunitiesManager): introduce `CreateHistoryArchiveTorrentFromMessages` API 2022-10-24 13:28:55 +02:00
manager_test.go feat(CommunitiesManager): introduce `CreateHistoryArchiveTorrentFromMessages` API 2022-10-24 13:28:55 +02:00
persistence.go fix(Communities): correct query params order when updating community 2022-10-24 12:02:52 +02:00
persistence_test.go feat: add `SpectateCommunity` api 2022-10-06 21:21:37 +02:00
persistence_test_helpers.go feat: add `SpectateCommunity` api 2022-10-06 21:21:37 +02:00
request_to_join.go feat: introduce and distribute RequestToLeave community 2022-08-26 11:25:33 +02:00
request_to_join_test.go Sync Communities (#2253) 2021-08-06 16:40:23 +01:00
request_to_leave.go feat: introduce and distribute RequestToLeave community 2022-08-26 11:25:33 +02:00
utils.go feat: introduce and distribute RequestToLeave community 2022-08-26 11:25:33 +02:00
validator.go feat: community tags (#2708) 2022-06-24 09:40:12 -04:00