1
1
import { NavigationPage } from '@/components/navigation/NavigationPage' ;
2
- import { clearData , db , syncErrorTracker } from '@/library/powersync/ConnectionManager' ;
2
+ import { clearData , db , sync , syncErrorTracker } from '@/library/powersync/ConnectionManager' ;
3
3
import {
4
4
Box ,
5
5
Button ,
46
46
stats.metadata_size,
47
47
IFNULL(stats.row_count, 0) as row_count,
48
48
local.download_size,
49
+ local.downloaded_operations,
49
50
local.total_operations,
50
51
local.downloading
51
52
FROM local_bucket_data local
64
65
0 as metadata_size,
65
66
0 as row_count,
66
67
local.download_size,
68
+ local.downloaded_operations,
67
69
local.total_operations,
68
70
local.downloading
69
71
FROM local_bucket_data local` ;
@@ -81,14 +83,23 @@ export default function SyncDiagnosticsPage() {
81
83
// Similar to db.currentState.hasSynced, but synchronized to the onChange events
82
84
const { synced_at } = await db . get < { synced_at : string | null } > ( 'SELECT powersync_last_synced_at() as synced_at' ) ;
83
85
setlastSyncedAt ( synced_at ? new Date ( synced_at + 'Z' ) : null ) ;
84
- if ( synced_at != null ) {
86
+ if ( synced_at != null && ! sync . syncStatus . dataFlowStatus . downloading ) {
85
87
// These are potentially expensive queries - do not run during initial sync
86
88
const bucketRows = await db . getAll ( BUCKETS_QUERY ) ;
87
89
const tableRows = await db . getAll ( TABLES_QUERY ) ;
88
90
setBucketRows ( bucketRows ) ;
89
91
setTableRows ( tableRows ) ;
92
+ } else if ( synced_at != null ) {
93
+ // Busy downloading, but have already synced once
94
+ const bucketRows = await db . getAll ( BUCKETS_QUERY_FAST ) ;
95
+ setBucketRows ( bucketRows ) ;
96
+ // Load tables if we haven't yet
97
+ if ( tableRows == null ) {
98
+ const tableRows = await db . getAll ( TABLES_QUERY ) ;
99
+ setTableRows ( tableRows ) ;
100
+ }
90
101
} else {
91
- // Fast query to show progress during initial sync
102
+ // Fast query to show progress during initial sync / while downloading bulk data
92
103
const bucketRows = await db . getAll ( BUCKETS_QUERY_FAST ) ;
93
104
setBucketRows ( bucketRows ) ;
94
105
setTableRows ( null ) ;
@@ -127,6 +138,7 @@ export default function SyncDiagnosticsPage() {
127
138
{ field : 'name' , headerName : 'Name' , flex : 2 } ,
128
139
{ field : 'tables' , headerName : 'Table(s)' , flex : 1 , type : 'text' } ,
129
140
{ field : 'row_count' , headerName : 'Row Count' , flex : 1 , type : 'number' } ,
141
+ { field : 'downloaded_operations' , headerName : 'Downloaded Operations' , flex : 1 , type : 'number' } ,
130
142
{ field : 'total_operations' , headerName : 'Total Operations' , flex : 1 , type : 'number' } ,
131
143
{
132
144
field : 'data_size' ,
@@ -163,6 +175,7 @@ export default function SyncDiagnosticsPage() {
163
175
name : r . name ,
164
176
tables : JSON . parse ( r . tables ?? '[]' ) . join ( ', ' ) ,
165
177
row_count : r . row_count ,
178
+ downloaded_operations : r . downloaded_operations ,
166
179
total_operations : r . total_operations ,
167
180
data_size : r . data_size ,
168
181
metadata_size : r . metadata_size ,
@@ -174,6 +187,7 @@ export default function SyncDiagnosticsPage() {
174
187
const totals = {
175
188
buckets : rows . length ,
176
189
row_count : rows . reduce ( ( total , row ) => total + row . row_count , 0 ) ,
190
+ downloaded_operations : rows . reduce ( ( total , row ) => total + row . downloaded_operations , 0 ) ,
177
191
total_operations : rows . reduce ( ( total , row ) => total + row . total_operations , 0 ) ,
178
192
data_size : rows . reduce ( ( total , row ) => total + row . data_size , 0 ) ,
179
193
metadata_size : rows . reduce ( ( total , row ) => total + row . metadata_size , 0 ) ,
@@ -208,6 +222,7 @@ export default function SyncDiagnosticsPage() {
208
222
Number of buckets
209
223
</ TableCell >
210
224
< TableCell component = "th" > Total Rows</ TableCell >
225
+ < TableCell component = "th" > Downloaded Operations</ TableCell >
211
226
< TableCell component = "th" > Total Operations</ TableCell >
212
227
< TableCell component = "th" > Total Data Size</ TableCell >
213
228
< TableCell component = "th" > Total Metadata Size</ TableCell >
@@ -217,6 +232,7 @@ export default function SyncDiagnosticsPage() {
217
232
< TableRow sx = { { '&:last-child td, &:last-child th' : { border : 0 } } } >
218
233
< TableCell align = "right" > { totals . buckets } </ TableCell >
219
234
< TableCell align = "right" > { totals . row_count } </ TableCell >
235
+ < TableCell align = "right" > { totals . downloaded_operations } </ TableCell >
220
236
< TableCell align = "right" > { totals . total_operations } </ TableCell >
221
237
< TableCell align = "right" > { formatBytes ( totals . data_size ) } </ TableCell >
222
238
< TableCell align = "right" > { formatBytes ( totals . metadata_size ) } </ TableCell >
0 commit comments