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:
@@ -67,22 +67,24 @@ router.get('/:id', requireRole('superadmin', 'admin'), async (req, res) => {
|
||||
// Create new API permission
|
||||
router.post('/', requireRole('superadmin', 'admin'), async (req, res) => {
|
||||
try {
|
||||
const { user_name, allowed_ips, allowed_domains, dispensary_id } = req.body;
|
||||
// Support both store_id (existing) and dispensary_id (for compatibility)
|
||||
const { user_name, allowed_ips, allowed_domains, store_id, dispensary_id } = req.body;
|
||||
const storeIdToUse = store_id || dispensary_id;
|
||||
|
||||
if (!user_name) {
|
||||
return res.status(400).json({ error: 'User name is required' });
|
||||
}
|
||||
|
||||
if (!dispensary_id) {
|
||||
return res.status(400).json({ error: 'Dispensary is required' });
|
||||
if (!storeIdToUse) {
|
||||
return res.status(400).json({ error: 'Store/Dispensary is required' });
|
||||
}
|
||||
|
||||
// Get dispensary name for display
|
||||
const dispensaryResult = await pool.query('SELECT name FROM dispensaries WHERE id = $1', [dispensary_id]);
|
||||
const dispensaryResult = await pool.query('SELECT name FROM dispensaries WHERE id = $1', [storeIdToUse]);
|
||||
if (dispensaryResult.rows.length === 0) {
|
||||
return res.status(400).json({ error: 'Invalid dispensary ID' });
|
||||
return res.status(400).json({ error: 'Invalid store/dispensary ID' });
|
||||
}
|
||||
const dispensaryName = dispensaryResult.rows[0].name;
|
||||
const storeName = dispensaryResult.rows[0].name;
|
||||
|
||||
const apiKey = generateApiKey();
|
||||
|
||||
@@ -93,8 +95,8 @@ router.post('/', requireRole('superadmin', 'admin'), async (req, res) => {
|
||||
allowed_ips,
|
||||
allowed_domains,
|
||||
is_active,
|
||||
dispensary_id,
|
||||
dispensary_name
|
||||
store_id,
|
||||
store_name
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, 1, $5, $6)
|
||||
RETURNING *
|
||||
@@ -103,8 +105,8 @@ router.post('/', requireRole('superadmin', 'admin'), async (req, res) => {
|
||||
apiKey,
|
||||
allowed_ips || null,
|
||||
allowed_domains || null,
|
||||
dispensary_id,
|
||||
dispensaryName
|
||||
storeIdToUse,
|
||||
storeName
|
||||
]);
|
||||
|
||||
res.status(201).json({
|
||||
|
||||
Reference in New Issue
Block a user