diff --git a/packages/datalib/src/PerspectiveDataProvider.ts b/packages/datalib/src/PerspectiveDataProvider.ts index d11e9b45c..7f1374f2b 100644 --- a/packages/datalib/src/PerspectiveDataProvider.ts +++ b/packages/datalib/src/PerspectiveDataProvider.ts @@ -4,7 +4,7 @@ import { format } from 'path'; import { PerspectiveBindingGroup, PerspectiveCache } from './PerspectiveCache'; import { PerspectiveDataLoader } from './PerspectiveDataLoader'; -const PERSPECTIVE_PAGE_SIZE = 100; +export const PERSPECTIVE_PAGE_SIZE = 10; export interface PerspectiveDatabaseConfig { conid: string; diff --git a/packages/datalib/src/PerspectiveDisplay.ts b/packages/datalib/src/PerspectiveDisplay.ts index d2db82d2f..70249dc77 100644 --- a/packages/datalib/src/PerspectiveDisplay.ts +++ b/packages/datalib/src/PerspectiveDisplay.ts @@ -76,13 +76,14 @@ export class PerspectiveDisplayRow { rowCellSkips: boolean[] = null; rowJoinIds: number[] = []; - incompleteRowsIndicator: string[] = null; + // incompleteRowsIndicator: string[] = null; } export class PerspectiveDisplay { columns: PerspectiveDisplayColumn[] = []; rows: PerspectiveDisplayRow[] = []; readonly columnLevelCount: number; + loadIndicatorsCounts: { [uniqueName: string]: number } = {}; constructor(public root: PerspectiveTreeNode, rows: any[]) { // dbg('source rows', rows); @@ -92,7 +93,7 @@ export class PerspectiveDisplay { } this.columnLevelCount = _max(this.columns.map(x => x.parentNodes.length)) + 1; const collectedRows = this.collectRows(rows, root.childNodes); - // dbg('collected rows', collectedRows); + dbg('collected rows', collectedRows); // console.log('COLLECTED', JSON.stringify(collectedRows, null, 2)); // this.mergeRows(collectedRows); this.mergeRows(collectedRows); @@ -212,16 +213,22 @@ export class PerspectiveDisplay { } mergeRow(collectedRow: CollectedPerspectiveDisplayRow, rowIndex: number): number { + if (collectedRow.incompleteRowsIndicator?.length > 0) { + for (const indicator of collectedRow.incompleteRowsIndicator) { + if (!this.loadIndicatorsCounts[indicator]) { + this.loadIndicatorsCounts[indicator] = rowIndex; + } + if (rowIndex < this.loadIndicatorsCounts[indicator]) { + this.loadIndicatorsCounts[indicator] = rowIndex; + } + } + return 0; + } + const mainRow = this.getRowAt(rowIndex); for (let i = 0; i < collectedRow.columnIndexes.length; i++) { mainRow.rowData[collectedRow.columnIndexes[i]] = collectedRow.rowData[i]; } - if (collectedRow.incompleteRowsIndicator) { - mainRow.incompleteRowsIndicator = [ - ...(mainRow.incompleteRowsIndicator || []), - ...collectedRow.incompleteRowsIndicator, - ]; - } let rowCount = 1; for (const subrows of collectedRow.subRowCollections) { diff --git a/packages/datalib/src/tests/PerspectiveDisplay.test.ts b/packages/datalib/src/tests/PerspectiveDisplay.test.ts index 44cc3a1c3..f794348c5 100644 --- a/packages/datalib/src/tests/PerspectiveDisplay.test.ts +++ b/packages/datalib/src/tests/PerspectiveDisplay.test.ts @@ -12,13 +12,17 @@ test('test flat view', () => { const root = new PerspectiveTableNode(artistTable, chinookDbInfo, createPerspectiveConfig(), null, null, null, null); const display = new PerspectiveDisplay(root, artistDataFlat); - console.log(display.rows); - expect(display.rows.length).toEqual(5); + // console.log(display.loadIndicatorsCounts); + // console.log(display.rows); + expect(display.rows.length).toEqual(4); expect(display.rows[0]).toEqual( expect.objectContaining({ rowData: ['AC/DC'], }) ); + expect(display.loadIndicatorsCounts).toEqual({ + Artist: 4, + }); }); test('test one level nesting', () => { @@ -34,8 +38,9 @@ test('test one level nesting', () => { ); const display = new PerspectiveDisplay(root, artistDataAlbum); - console.log(display.rows); - expect(display.rows.length).toEqual(7); + console.log(display.loadIndicatorsCounts); + // console.log(display.rows); + expect(display.rows.length).toEqual(6); expect(display.rows[0]).toEqual( expect.objectContaining({ rowData: ['AC/DC', 'For Those About To Rock We Salute You'], @@ -63,6 +68,11 @@ test('test one level nesting', () => { rowSpans: [1, 1], }) ); + + expect(display.loadIndicatorsCounts).toEqual({ + Artist: 6, + 'Artist.Album': 6, + }); }); test('test two level nesting', () => { @@ -79,7 +89,7 @@ test('test two level nesting', () => { const display = new PerspectiveDisplay(root, artistDataAlbumTrack); console.log(display.rows); - expect(display.rows.length).toEqual(9); + expect(display.rows.length).toEqual(8); expect(display.rows[0]).toEqual( expect.objectContaining({ rowData: ['AC/DC', 'For Those About To Rock We Salute You', 'For Those About To Rock (We Salute You)'], diff --git a/packages/datalib/src/tests/artistDataAlbum.ts b/packages/datalib/src/tests/artistDataAlbum.ts index 90c5d5cb0..bcf2bf86f 100644 --- a/packages/datalib/src/tests/artistDataAlbum.ts +++ b/packages/datalib/src/tests/artistDataAlbum.ts @@ -1,55 +1,56 @@ export default [ - { - "ArtistId": 1, - "Name": "AC/DC", - "Album": [ - { - "Title": "For Those About To Rock We Salute You", - "ArtistId": 1 - }, - { - "Title": "Let There Be Rock", - "ArtistId": 1 - } - ] - }, - { - "ArtistId": 2, - "Name": "Accept", - "Album": [ - { - "Title": "Balls to the Wall", - "ArtistId": 2 - }, - { - "Title": "Restless and Wild", - "ArtistId": 2 - } - ] - }, - { - "ArtistId": 3, - "Name": "Aerosmith", - "Album": [ - { - "Title": "Big Ones", - "ArtistId": 3 - } - ] - }, - { - "ArtistId": 4, - "Name": "Alanis Morissette", - "Album": [ - { - "Title": "Jagged Little Pill", - "ArtistId": 4 - } - ] - }, - { - "incompleteRowsIndicator": [ - "Artist" - ] - } - ] \ No newline at end of file + { + ArtistId: 1, + Name: 'AC/DC', + Album: [ + { + Title: 'For Those About To Rock We Salute You', + ArtistId: 1, + }, + { + Title: 'Let There Be Rock', + ArtistId: 1, + }, + ], + }, + { + ArtistId: 2, + Name: 'Accept', + Album: [ + { + Title: 'Balls to the Wall', + ArtistId: 2, + }, + { + Title: 'Restless and Wild', + ArtistId: 2, + }, + ], + }, + { + ArtistId: 3, + Name: 'Aerosmith', + Album: [ + { + Title: 'Big Ones', + ArtistId: 3, + }, + ], + }, + { + ArtistId: 4, + Name: 'Alanis Morissette', + Album: [ + { + Title: 'Jagged Little Pill', + ArtistId: 4, + }, + { + incompleteRowsIndicator: ['Artist.Album'], + }, + ], + }, + { + incompleteRowsIndicator: ['Artist'], + }, +]; diff --git a/packages/web/src/perspectives/PerspectiveIntersectionObserver.svelte b/packages/web/src/perspectives/PerspectiveIntersectionObserver.svelte index 4951c7fc7..06ae0d4e3 100644 --- a/packages/web/src/perspectives/PerspectiveIntersectionObserver.svelte +++ b/packages/web/src/perspectives/PerspectiveIntersectionObserver.svelte @@ -3,6 +3,7 @@ export let rootNode; export let onLoadNext; + export let incompleteRowsIndicator; let domObserved; @@ -30,4 +31,4 @@ }); -