fix(monitor): remove non-existent worker columns from job_run_logs query
The job_run_logs table tracks scheduled job orchestration, not individual worker jobs. Worker info (worker_id, worker_hostname) belongs on dispensary_crawl_jobs, not job_run_logs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,8 +23,8 @@ interface ApiKeyPermission {
|
||||
allowed_ips: string | null;
|
||||
allowed_domains: string | null;
|
||||
is_active: number;
|
||||
dispensary_id: number;
|
||||
dispensary_name: string;
|
||||
store_id: number;
|
||||
store_name: string;
|
||||
dutchie_az_store_id?: number;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ async function validatePublicApiKey(
|
||||
}
|
||||
|
||||
try {
|
||||
// Query WordPress permissions table with dispensary info
|
||||
// Query WordPress permissions table with store info
|
||||
const result = await pool.query<ApiKeyPermission>(`
|
||||
SELECT
|
||||
p.id,
|
||||
@@ -135,8 +135,8 @@ async function validatePublicApiKey(
|
||||
p.allowed_ips,
|
||||
p.allowed_domains,
|
||||
p.is_active,
|
||||
p.dispensary_id,
|
||||
p.dispensary_name
|
||||
p.store_id,
|
||||
p.store_name
|
||||
FROM wp_dutchie_api_permissions p
|
||||
WHERE p.api_key = $1 AND p.is_active = 1
|
||||
`, [apiKey]);
|
||||
@@ -181,8 +181,8 @@ async function validatePublicApiKey(
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve the dutchie_az store for this dispensary
|
||||
// Match by dispensary name (from main DB) to dutchie_az.dispensaries.name
|
||||
// Resolve the dutchie_az store for this store
|
||||
// Match by store name (from main DB) to dutchie_az.dispensaries.name
|
||||
const storeResult = await dutchieAzQuery<{ id: number }>(`
|
||||
SELECT id FROM dispensaries
|
||||
WHERE LOWER(TRIM(name)) = LOWER(TRIM($1))
|
||||
@@ -192,7 +192,7 @@ async function validatePublicApiKey(
|
||||
CASE WHEN LOWER(TRIM(name)) = LOWER(TRIM($1)) THEN 0 ELSE 1 END,
|
||||
id
|
||||
LIMIT 1
|
||||
`, [permission.dispensary_name]);
|
||||
`, [permission.store_name]);
|
||||
|
||||
if (storeResult.rows.length > 0) {
|
||||
permission.dutchie_az_store_id = storeResult.rows[0].id;
|
||||
@@ -243,8 +243,8 @@ router.get('/products', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available. The dispensary may not be set up in the new data pipeline.`,
|
||||
dispensary_name: permission.dispensary_name
|
||||
message: `Menu data for ${permission.store_name} is not yet available. The dispensary may not be set up in the new data pipeline.`,
|
||||
dispensary_name: permission.store_name
|
||||
});
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ router.get('/products', async (req: PublicApiRequest, res: Response) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
dispensary: permission.dispensary_name,
|
||||
dispensary: permission.store_name,
|
||||
products: transformedProducts,
|
||||
pagination: {
|
||||
total: parseInt(countRows[0]?.total || '0', 10),
|
||||
@@ -405,7 +405,7 @@ router.get('/products/:id', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available.`
|
||||
message: `Menu data for ${permission.store_name} is not yet available.`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ router.get('/categories', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available.`
|
||||
message: `Menu data for ${permission.store_name} is not yet available.`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ router.get('/categories', async (req: PublicApiRequest, res: Response) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
dispensary: permission.dispensary_name,
|
||||
dispensary: permission.store_name,
|
||||
categories
|
||||
});
|
||||
} catch (error: any) {
|
||||
@@ -534,7 +534,7 @@ router.get('/brands', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available.`
|
||||
message: `Menu data for ${permission.store_name} is not yet available.`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ router.get('/brands', async (req: PublicApiRequest, res: Response) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
dispensary: permission.dispensary_name,
|
||||
dispensary: permission.store_name,
|
||||
brands
|
||||
});
|
||||
} catch (error: any) {
|
||||
@@ -574,7 +574,7 @@ router.get('/specials', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available.`
|
||||
message: `Menu data for ${permission.store_name} is not yet available.`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ router.get('/specials', async (req: PublicApiRequest, res: Response) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
dispensary: permission.dispensary_name,
|
||||
dispensary: permission.store_name,
|
||||
specials: transformedProducts,
|
||||
pagination: {
|
||||
total: parseInt(countRows[0]?.total || '0', 10),
|
||||
@@ -676,7 +676,7 @@ router.get('/menu', async (req: PublicApiRequest, res: Response) => {
|
||||
if (!permission.dutchie_az_store_id) {
|
||||
return res.status(503).json({
|
||||
error: 'No menu data available',
|
||||
message: `Menu data for ${permission.dispensary_name} is not yet available.`
|
||||
message: `Menu data for ${permission.store_name} is not yet available.`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ router.get('/menu', async (req: PublicApiRequest, res: Response) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
dispensary: permission.dispensary_name,
|
||||
dispensary: permission.store_name,
|
||||
menu: {
|
||||
total_products: parseInt(summary.total_products || '0', 10),
|
||||
in_stock_count: parseInt(summary.in_stock_count || '0', 10),
|
||||
|
||||
Reference in New Issue
Block a user