refactor(sql): moved new queries to there own folder to make it more easy to work and migrate

This commit is contained in:
2026-02-16 19:01:23 -06:00
parent ace73fa919
commit 44d0cb63cf
5 changed files with 51 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
/*
checks the age of an inventory dose not exceed x time
*/
use AlplaPROD_test1
DECLARE @timeCheck INT = [timeTest]
select
w.IdWarenLager as idWarehouse
,w.KurzBezeichnung as warehouse
,b.IdLagerAbteilung as locationId
,x.KurzBezeichnung as 'location'
--,case when b.upd_date < Dateadd(minute, -(@timeCheck * 1.5), getdate()) then 'OVERDUE' else 'In-Progress' end as invStatus
,format(b.Upd_Date, 'M/d/yyyy HH:mm') as cycleCountStartAt
,b.Upd_User as blockedBy
--,*
from [dbo].[V_LagerAbteilungenInventuren] (nolock) as b
-- get the loction name
left join
dbo.T_LagerAbteilungen (nolock) as x
on x.IdLagerAbteilung = b.IdLagerAbteilung
-- get the whse
left join
dbo.T_WarenLager (nolock) as w
on x.idWarenLager = w.idWarenLager
where status = 1
and b.Upd_Date < Dateadd(minute, -@timeCheck, getdate())

View File

@@ -0,0 +1,8 @@
/*
disables sql jobs.
*/
DECLARE @JobName varchar(max) = '[jobName]'
UPDATE msdb.dbo.sysjobs
SET enabled = 0
WHERE name = @JobName;

View File

@@ -1,14 +1,21 @@
import { readFileSync } from "fs";
export type SqlQuery = {
query: string;
success: boolean;
message: string;
};
export const sqlQuerySelector = (name: string) => {
try {
const queryFile = readFileSync(
new URL(`../querys/${name}.sql`, import.meta.url),
new URL(`../querys/newQueries/${name}.sql`, import.meta.url),
"utf8",
);
return {
success: true,
message: `Query for: ${name}`,
query: queryFile,
};
} catch (error) {