forked from mystiq/hydrogen-web
add more logging during gap filling
This commit is contained in:
parent
f55f450850
commit
0846fcc05d
1 changed files with 7 additions and 2 deletions
|
@ -27,14 +27,18 @@ export class GapWriter {
|
||||||
this._relationWriter = relationWriter;
|
this._relationWriter = relationWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _findOverlappingEvents(fragmentEntry, events, txn) {
|
async _findOverlappingEvents(fragmentEntry, events, txn, log) {
|
||||||
const eventIds = events.map(e => e.event_id);
|
const eventIds = events.map(e => e.event_id);
|
||||||
const existingEventKeyMap = await txn.timelineEvents.getEventKeysForIds(this._roomId, eventIds);
|
const existingEventKeyMap = await txn.timelineEvents.getEventKeysForIds(this._roomId, eventIds);
|
||||||
|
log.set("existingEvents", existingEventKeyMap.size);
|
||||||
const nonOverlappingEvents = events.filter(e => !existingEventKeyMap.has(e.event_id));
|
const nonOverlappingEvents = events.filter(e => !existingEventKeyMap.has(e.event_id));
|
||||||
|
log.set("nonOverlappingEvents", nonOverlappingEvents.length);
|
||||||
let neighbourFragmentEntry;
|
let neighbourFragmentEntry;
|
||||||
if (fragmentEntry.hasLinkedFragment) {
|
if (fragmentEntry.hasLinkedFragment) {
|
||||||
|
log.set("linkedFragmentId", fragmentEntry.linkedFragmentId);
|
||||||
for (const eventKey of existingEventKeyMap.values()) {
|
for (const eventKey of existingEventKeyMap.values()) {
|
||||||
if (eventKey.fragmentId === fragmentEntry.linkedFragmentId) {
|
if (eventKey.fragmentId === fragmentEntry.linkedFragmentId) {
|
||||||
|
log.set("foundLinkedFragment", true);
|
||||||
const neighbourFragment = await txn.timelineFragments.get(this._roomId, fragmentEntry.linkedFragmentId);
|
const neighbourFragment = await txn.timelineFragments.get(this._roomId, fragmentEntry.linkedFragmentId);
|
||||||
neighbourFragmentEntry = fragmentEntry.createNeighbourEntry(neighbourFragment);
|
neighbourFragmentEntry = fragmentEntry.createNeighbourEntry(neighbourFragment);
|
||||||
break;
|
break;
|
||||||
|
@ -183,11 +187,12 @@ export class GapWriter {
|
||||||
|
|
||||||
// find last event in fragment so we get the eventIndex to begin creating keys at
|
// find last event in fragment so we get the eventIndex to begin creating keys at
|
||||||
let lastKey = await this._findFragmentEdgeEventKey(fragmentEntry, txn);
|
let lastKey = await this._findFragmentEdgeEventKey(fragmentEntry, txn);
|
||||||
|
log.set("lastKey", lastKey.toString());
|
||||||
// find out if any event in chunk is already present using findFirstOrLastOccurringEventId
|
// find out if any event in chunk is already present using findFirstOrLastOccurringEventId
|
||||||
const {
|
const {
|
||||||
nonOverlappingEvents,
|
nonOverlappingEvents,
|
||||||
neighbourFragmentEntry
|
neighbourFragmentEntry
|
||||||
} = await this._findOverlappingEvents(fragmentEntry, chunk, txn);
|
} = await this._findOverlappingEvents(fragmentEntry, chunk, txn, log);
|
||||||
// create entries for all events in chunk, add them to entries
|
// create entries for all events in chunk, add them to entries
|
||||||
const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn, log);
|
const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn, log);
|
||||||
const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn, log);
|
const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn, log);
|
||||||
|
|
Loading…
Reference in a new issue