Skip to content

Commit

Permalink
UI: Better mirror fetching (#852)
Browse files Browse the repository at this point in the history
The mirror fetch API was sending data in the wrong format, causing the
mirrors page to crash when qrep mirrors exist. This PR restores
functionality of the mirrors page
  • Loading branch information
Amogh-Bharadwaj authored Dec 19, 2023
1 parent 476549b commit 51bc1a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 3 additions & 11 deletions ui/app/api/mirrors/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ import prisma from '@/app/utils/prisma';

export const dynamic = 'force-dynamic';

const stringifyConfig = (flowArray: any[]) => {
flowArray.forEach((flow) => {
if (flow.config_proto) {
flow.config_proto = new TextDecoder().decode(flow.config_proto);
}
});
return flowArray;
};

export async function GET(request: Request) {
const mirrors = await prisma.flows.findMany({
distinct: 'name',
Expand All @@ -21,13 +12,14 @@ export async function GET(request: Request) {
},
});

const flows = mirrors?.map((mirror) => {
// using any as type because of the way prisma returns data
const flows = mirrors?.map((mirror: any) => {
let newMirror: any = {
...mirror,
sourcePeer: getTruePeer(mirror.sourcePeer),
destinationPeer: getTruePeer(mirror.destinationPeer),
};
return newMirror;
});
return new Response(JSON.stringify(stringifyConfig(flows)));
return new Response(JSON.stringify(flows));
}
4 changes: 2 additions & 2 deletions ui/app/mirrors/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Mirrors() {

let qrepFlows = flows?.filter((flow) => {
if (flow.config_proto && flow.query_string) {
let config = QRepConfig.decode(flow.config_proto);
let config = QRepConfig.decode(flow.config_proto.data);
const watermarkCol = config.watermarkColumn.toLowerCase();
return watermarkCol !== 'xmin' && watermarkCol !== 'ctid';
}
Expand All @@ -40,7 +40,7 @@ export default function Mirrors() {

let xminFlows = flows?.filter((flow) => {
if (flow.config_proto && flow.query_string) {
let config = QRepConfig.decode(flow.config_proto);
let config = QRepConfig.decode(flow.config_proto.data);
return config.watermarkColumn.toLowerCase() === 'xmin';
}
return false;
Expand Down

0 comments on commit 51bc1a2

Please sign in to comment.