Skip to content
Snippets Groups Projects
Commit 3b664347 authored by permcu's avatar permcu
Browse files

Start with fetchMore

parent 5d2233e7
No related branches found
No related tags found
No related merge requests found
...@@ -345,20 +345,27 @@ export default { ...@@ -345,20 +345,27 @@ export default {
assureDate(date) { assureDate(date) {
if (!this.knownDates[date]) { if (!this.knownDates[date]) {
// find missing & fetch missing range // find missing & fetch missing range
// date +- 5 days ? const missing = this.dateRange(date).filter((ts) => !this.docsByDay[ts] );
const dateRange = Interval // ask for first to last
.fromDateTimes(date.minus({ days: 3 }), date.plus({ days: 4 })) this.lastQuery.fetchMore({
.splitBy({ days: 1 }) variables: {
.map((ts) => ts.start); dateStart: missing[0].toISODate(),
console.log('assureDate', dateRange.map((ts) => ts.toISODate())); dateEnd: missing[missing.length - 1].toISODate(),
// look up in docsByDay },
console.log('missing', dateRange.map((ts) => this.docsByDay[ts] )); // Transform the previous result with new data
console.log('missing', dateRange.filter((ts) => !this.docsByDay[ts] )); updateQuery: (previousResult, { fetchMoreResult }) => {
// dateRange.forEach((ts) => { this.docsByDay[ts.toISODate()] = 42 });
console.log('docsByDay', this.docsByDay); return {
console.log('2024-03-29', this.docsByDay[DateTime.fromISO('2024-03-29')]); tagsPage: {
console.log('2024-03-29', dateRange[3], this.docsByDay[dateRange[3]]); __typename: previousResult.tagsPage.__typename,
// sort missing and ask for first to last // Merging the tag list
tags: [...previousResult.tagsPage.tags, ...newTags],
hasMore,
},
}
},
})
// integrate into docsByDay // integrate into docsByDay
} }
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment