-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fb024f
commit 90d467f
Showing
9 changed files
with
276 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
nexus/catalog/migrations/V10__mirror_drop_bad_constraints.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Drop the foreign key constraint from qrep_partitions to qrep_runs | ||
ALTER TABLE peerdb_stats.qrep_partitions | ||
DROP CONSTRAINT fk_qrep_partitions_run_uuid; | ||
|
||
-- Drop the unique constraint for flow_name from qrep_runs | ||
ALTER TABLE peerdb_stats.qrep_runs | ||
DROP CONSTRAINT uq_qrep_runs_flow_name; | ||
|
||
-- Add unique constraint to qrep_runs for (flow_name, run_uuid) | ||
ALTER TABLE peerdb_stats.qrep_runs | ||
ADD CONSTRAINT uq_qrep_runs_flow_run | ||
UNIQUE (flow_name, run_uuid); | ||
|
||
-- Add foreign key from qrep_partitions to qrep_runs | ||
ALTER TABLE peerdb_stats.qrep_partitions | ||
ADD CONSTRAINT fk_qrep_partitions_run | ||
FOREIGN KEY (flow_name, run_uuid) | ||
REFERENCES peerdb_stats.qrep_runs(flow_name, run_uuid) | ||
ON DELETE CASCADE; |
5 changes: 5 additions & 0 deletions
5
nexus/catalog/migrations/V11__qrep_runs_start_time_nullable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE peerdb_stats.qrep_runs | ||
ALTER COLUMN start_time DROP NOT NULL; | ||
|
||
ALTER TABLE peerdb_stats.qrep_partitions | ||
ALTER COLUMN start_time DROP NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import prisma from '@/app/utils/prisma'; | ||
import { Header } from '@/lib/Header'; | ||
import { LayoutMain } from '@/lib/Layout'; | ||
import QRepStatusTable, { QRepPartitionStatus } from './qrepStatusTable'; | ||
|
||
type QRepMirrorStatusProps = { | ||
params: { mirrorId: string }; | ||
}; | ||
|
||
export default async function QRepMirrorStatus({ | ||
params: { mirrorId }, | ||
}: QRepMirrorStatusProps) { | ||
const runs = await prisma.qrep_partitions.findMany({ | ||
where: { | ||
flow_name: mirrorId, | ||
start_time: { | ||
not: null, | ||
}, | ||
}, | ||
orderBy: { | ||
start_time: 'desc', | ||
}, | ||
}); | ||
|
||
const partitions = runs.map((run) => { | ||
let ret: QRepPartitionStatus = { | ||
partitionId: run.partition_uuid, | ||
runUuid: run.run_uuid, | ||
startTime: run.start_time, | ||
endTime: run.end_time, | ||
numRows: run.rows_in_partition, | ||
status: '', | ||
}; | ||
return ret; | ||
}); | ||
|
||
return ( | ||
<LayoutMain alignSelf='flex-start' justifySelf='flex-start' width='full'> | ||
<Header variant='title2'>{mirrorId}</Header> | ||
<QRepStatusTable flowJobName={mirrorId} partitions={partitions} /> | ||
</LayoutMain> | ||
); | ||
} |
146 changes: 146 additions & 0 deletions
146
ui/app/mirrors/status/qrep/[mirrorId]/qrepStatusTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
'use client'; | ||
|
||
import { Button } from '@/lib/Button'; | ||
import { Checkbox } from '@/lib/Checkbox'; | ||
import { Icon } from '@/lib/Icon'; | ||
import { Label } from '@/lib/Label'; | ||
import { ProgressCircle } from '@/lib/ProgressCircle'; | ||
import { SearchField } from '@/lib/SearchField'; | ||
import { Table, TableCell, TableRow } from '@/lib/Table'; | ||
import moment from 'moment'; | ||
import { useState } from 'react'; | ||
|
||
export type QRepPartitionStatus = { | ||
partitionId: string; | ||
runUuid: string; | ||
status: string; | ||
startTime: Date | null; | ||
endTime: Date | null; | ||
numRows: number | null; | ||
}; | ||
|
||
function TimeOrProgressBar({ time }: { time: Date | null }) { | ||
if (time === null) { | ||
return <ProgressCircle variant='determinate_progress_circle' />; | ||
} else { | ||
return <Label>{moment(time)?.format('YYYY-MM-DD HH:mm:ss')}</Label>; | ||
} | ||
} | ||
|
||
function RowPerPartition({ | ||
partitionId, | ||
runUuid, | ||
status, | ||
startTime, | ||
endTime, | ||
numRows, | ||
}: QRepPartitionStatus) { | ||
return ( | ||
<TableRow key={partitionId}> | ||
<TableCell variant='button'> | ||
<Checkbox /> | ||
</TableCell> | ||
<TableCell> | ||
<Label>{partitionId}</Label> | ||
</TableCell> | ||
<TableCell> | ||
<Label>{runUuid}</Label> | ||
</TableCell> | ||
<TableCell> | ||
<Label>{moment(startTime)?.format('YYYY-MM-DD HH:mm:ss')}</Label> | ||
</TableCell> | ||
<TableCell> | ||
<Label> | ||
<TimeOrProgressBar time={endTime} /> | ||
</Label> | ||
</TableCell> | ||
<TableCell> | ||
<Label>{numRows}</Label> | ||
</TableCell> | ||
</TableRow> | ||
); | ||
} | ||
|
||
type QRepStatusTableProps = { | ||
flowJobName: string; | ||
partitions: QRepPartitionStatus[]; | ||
}; | ||
|
||
export default function QRepStatusTable({ | ||
flowJobName, | ||
partitions, | ||
}: QRepStatusTableProps) { | ||
const ROWS_PER_PAGE = 10; | ||
const [currentPage, setCurrentPage] = useState(1); | ||
const totalPages = Math.ceil(partitions.length / ROWS_PER_PAGE); | ||
|
||
const visiblePartitions = partitions.slice( | ||
(currentPage - 1) * ROWS_PER_PAGE, | ||
currentPage * ROWS_PER_PAGE | ||
); | ||
|
||
const handleNext = () => { | ||
if (currentPage < totalPages) setCurrentPage(currentPage + 1); | ||
}; | ||
|
||
const handlePrevious = () => { | ||
if (currentPage > 1) setCurrentPage(currentPage - 1); | ||
}; | ||
|
||
return ( | ||
<Table | ||
title={<Label variant='headline'>Progress</Label>} | ||
toolbar={{ | ||
left: ( | ||
<> | ||
<Button | ||
variant='normalBorderless' | ||
onClick={handlePrevious} | ||
disabled={currentPage === 1} | ||
> | ||
<Icon name='chevron_left' /> | ||
</Button> | ||
<Button | ||
variant='normalBorderless' | ||
onClick={handleNext} | ||
disabled={currentPage === totalPages} | ||
> | ||
<Icon name='chevron_right' /> | ||
</Button> | ||
<Button variant='normalBorderless'> | ||
<Icon name='refresh' /> | ||
</Button> | ||
<Button variant='normalBorderless'> | ||
<Icon name='help' /> | ||
</Button> | ||
<Button variant='normalBorderless' disabled> | ||
<Icon name='download' /> | ||
</Button> | ||
<div> | ||
<Label> | ||
{currentPage} of {totalPages} | ||
</Label> | ||
</div> | ||
</> | ||
), | ||
right: <SearchField placeholder='Search' />, | ||
}} | ||
header={ | ||
<TableRow> | ||
<TableCell as='th' variant='button'> | ||
<Checkbox variant='mixed' defaultChecked /> | ||
</TableCell> | ||
<TableCell as='th'>Partition UUID</TableCell> | ||
<TableCell as='th'>Run UUID</TableCell> | ||
<TableCell as='th'>Start Time</TableCell> | ||
<TableCell as='th'>End Time</TableCell> | ||
<TableCell as='th'>Num Rows Synced</TableCell> | ||
</TableRow> | ||
} | ||
> | ||
{visiblePartitions.map((partition, index) => ( | ||
<RowPerPartition key={index} {...partition} /> | ||
))} | ||
</Table> | ||
); | ||
} |
Oops, something went wrong.