Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Better mirror fetching #852

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading