feat(MED-87): improve naming
This commit is contained in:
@@ -11,7 +11,7 @@ import { loadUserAnalysis } from '../../_lib/server/load-user-analysis';
|
||||
import Analysis from './_components/analysis';
|
||||
import pathsConfig from '~/config/paths.config';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getOrders } from '~/lib/services/order.service';
|
||||
import { getAnalysisOrders } from '~/lib/services/order.service';
|
||||
import { getAnalysisElements } from '~/lib/services/analysis-element.service';
|
||||
import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account';
|
||||
import { createPageViewLog } from '~/lib/services/audit/pageView.service';
|
||||
@@ -34,9 +34,9 @@ async function AnalysisResultsPage() {
|
||||
const analysisResponses = await loadUserAnalysis();
|
||||
const analysisResponseElements = analysisResponses?.flatMap(({ elements }) => elements);
|
||||
|
||||
const orders = await getOrders().catch(() => null);
|
||||
const analysisOrders = await getAnalysisOrders().catch(() => null);
|
||||
|
||||
if (!orders) {
|
||||
if (!analysisOrders) {
|
||||
redirect(pathsConfig.auth.signIn);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ async function AnalysisResultsPage() {
|
||||
});
|
||||
|
||||
const analysisElementIds = [
|
||||
...new Set(orders?.flatMap((order) => order.analysis_element_ids).filter(Boolean) as number[]),
|
||||
...new Set(analysisOrders?.flatMap((order) => order.analysis_element_ids).filter(Boolean) as number[]),
|
||||
];
|
||||
const analysisElements = await getAnalysisElements({ ids: analysisElementIds });
|
||||
const analysisElementsWithResults = analysisResponseElements
|
||||
|
||||
@@ -10,7 +10,7 @@ import { HomeLayoutPageHeader } from '../../_components/home-page-header';
|
||||
import OrdersTable from '../../_components/orders/orders-table';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
import type { IOrderLineItem } from '../../_components/orders/types';
|
||||
import { getOrders } from '~/lib/services/order.service';
|
||||
import { getAnalysisOrders } from '~/lib/services/order.service';
|
||||
|
||||
export async function generateMetadata() {
|
||||
const { t } = await createI18nServerInstance();
|
||||
@@ -21,19 +21,19 @@ export async function generateMetadata() {
|
||||
}
|
||||
|
||||
async function OrdersPage() {
|
||||
const orders = await listOrders();
|
||||
const localOrders = await getOrders();
|
||||
const medusaOrders = await listOrders();
|
||||
const analysisOrders = await getAnalysisOrders();
|
||||
const { productTypes } = await listProductTypes();
|
||||
|
||||
if (!orders || !productTypes) {
|
||||
if (!medusaOrders || !productTypes) {
|
||||
redirect(pathsConfig.auth.signIn);
|
||||
}
|
||||
|
||||
const analysisPackagesType = productTypes.find(({ metadata }) => metadata?.handle === 'analysis-packages');
|
||||
const analysisPackageOrders: IOrderLineItem[] = orders.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
const analysisPackageOrders: IOrderLineItem[] = medusaOrders.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
?.filter((item) => item.product_type_id === analysisPackagesType?.id)
|
||||
.map((item) => {
|
||||
const localOrder = localOrders.find((order) => order.medusa_order_id === id);
|
||||
const localOrder = analysisOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!localOrder) {
|
||||
return null;
|
||||
}
|
||||
@@ -48,19 +48,19 @@ async function OrdersPage() {
|
||||
.filter((order) => order !== null)
|
||||
|| []);
|
||||
|
||||
const otherOrders: IOrderLineItem[] = orders
|
||||
const otherOrders: IOrderLineItem[] = medusaOrders
|
||||
.filter(({ items }) => items?.some((item) => item.product_type_id !== analysisPackagesType?.id))
|
||||
.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
?.map((item) => {
|
||||
const localOrder = localOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!localOrder) {
|
||||
const analysisOrder = analysisOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!analysisOrder) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
item,
|
||||
medusaOrderId: id,
|
||||
orderId: localOrder.id,
|
||||
orderStatus: localOrder.status,
|
||||
orderId: analysisOrder.id,
|
||||
orderStatus: analysisOrder.status,
|
||||
}
|
||||
})
|
||||
.filter((order) => order !== null)
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* This file is used to register monitoring instrumentation
|
||||
* for your Next.js application.
|
||||
*/
|
||||
import { type Instrumentation } from 'next';
|
||||
|
||||
const isEnabledInDev = process.env.ENABLE_LOCAL_JOBS === 'true';
|
||||
@@ -59,7 +55,6 @@ async function registerJobScheduler() {
|
||||
}
|
||||
isRunning = true;
|
||||
try {
|
||||
// Ensure env variables are loaded for the handler
|
||||
try {
|
||||
const { default: loadEnv } = await import('./app/api/job/handler/load-env');
|
||||
loadEnv();
|
||||
@@ -72,7 +67,6 @@ async function registerJobScheduler() {
|
||||
);
|
||||
await syncAnalysisResults();
|
||||
} catch (error) {
|
||||
// Log and continue; do not crash the process
|
||||
console.error('Scheduled job syncAnalysisResults failed:', error);
|
||||
} finally {
|
||||
isRunning = false;
|
||||
|
||||
@@ -79,7 +79,7 @@ export async function getOrder({
|
||||
return order;
|
||||
}
|
||||
|
||||
export async function getOrders({
|
||||
export async function getAnalysisOrders({
|
||||
orderStatus,
|
||||
}: {
|
||||
orderStatus?: Tables<{ schema: 'medreport' }, 'analysis_orders'>['status'];
|
||||
|
||||
Reference in New Issue
Block a user