refactor(scanner): logging - version of app
This commit is contained in:
@@ -11,6 +11,7 @@ export const scanLog = pgTable("scan_log", {
|
|||||||
commandDescription: text("command_description"),
|
commandDescription: text("command_description"),
|
||||||
runningNumber: text("running_number").default("0"),
|
runningNumber: text("running_number").default("0"),
|
||||||
status: text("status"),
|
status: text("status"),
|
||||||
|
scannerVersion: text("scanner_version").default("0"),
|
||||||
lines: jsonb("lines").default([]),
|
lines: jsonb("lines").default([]),
|
||||||
add_Date: timestamp("add_date").defaultNow(),
|
add_Date: timestamp("add_date").defaultNow(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
|
import { eq, sql } from "drizzle-orm";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
import { db } from "../db/db.controller.js";
|
import { db } from "../db/db.controller.js";
|
||||||
import { scanLog } from "../db/schema/scanlog.schema.js";
|
import { scanLog } from "../db/schema/scanlog.schema.js";
|
||||||
|
import { scanUser } from "../db/schema/scanUsers.js";
|
||||||
import { apiReturn } from "../utils/returnHelper.utils.js";
|
import { apiReturn } from "../utils/returnHelper.utils.js";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.post("/", async (req, res) => {
|
router.post("/", async (req, res) => {
|
||||||
const body = req.body;
|
const body = req.body;
|
||||||
|
try {
|
||||||
|
await db
|
||||||
|
.update(scanUser)
|
||||||
|
.set({ lastScan: sql`NOW()` })
|
||||||
|
.where(eq(scanUser.name, body.name));
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
const newLog = await db
|
const newLog = await db
|
||||||
.insert(scanLog)
|
.insert(scanLog)
|
||||||
.values({
|
.values({
|
||||||
@@ -20,6 +28,7 @@ router.post("/", async (req, res) => {
|
|||||||
lines: body.lines ?? "",
|
lines: body.lines ?? "",
|
||||||
user: body.user ?? "",
|
user: body.user ?? "",
|
||||||
runningNumber: body.runningNumber ?? "",
|
runningNumber: body.runningNumber ?? "",
|
||||||
|
scannerVersion: body.scannerVersion ?? "0",
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
"foregroundImage": "./assets/adaptive-icon-white.png",
|
"foregroundImage": "./assets/adaptive-icon-white.png",
|
||||||
"backgroundColor": "#ffffff"
|
"backgroundColor": "#ffffff"
|
||||||
},
|
},
|
||||||
"versionCode": 33,
|
"versionCode": 34,
|
||||||
"minSupportedVersionCode": 33,
|
"minSupportedVersionCode": 33,
|
||||||
"predictiveBackGestureEnabled": false,
|
"predictiveBackGestureEnabled": false,
|
||||||
"package": "net.alpla.lst.mobile"
|
"package": "net.alpla.lst.mobile"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { format } from "date-fns-tz";
|
import { format } from "date-fns-tz";
|
||||||
|
import Constants from "expo-constants";
|
||||||
import { Redirect, useFocusEffect, useRouter } from "expo-router";
|
import { Redirect, useFocusEffect, useRouter } from "expo-router";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Alert, Button, Text, View } from "react-native";
|
import { Alert, Button, Text, View } from "react-native";
|
||||||
@@ -31,6 +32,7 @@ export default function LSTScanner() {
|
|||||||
const [tagScans, setTagScans] = useState<any>([]);
|
const [tagScans, setTagScans] = useState<any>([]);
|
||||||
const serverIp = useAppStore((s) => s.serverIp);
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
const [bgColor, setBGColor] = useState<string | null>(null);
|
const [bgColor, setBGColor] = useState<string | null>(null);
|
||||||
|
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||||
|
|
||||||
const handleScan = useCallback(
|
const handleScan = useCallback(
|
||||||
async (scan: ZebraScanResult) => {
|
async (scan: ZebraScanResult) => {
|
||||||
@@ -93,6 +95,7 @@ export default function LSTScanner() {
|
|||||||
: scan.data.startsWith("loc")
|
: scan.data.startsWith("loc")
|
||||||
? scan.data
|
? scan.data
|
||||||
: "0",
|
: "0",
|
||||||
|
scannerVersion: build,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@@ -146,6 +149,7 @@ export default function LSTScanner() {
|
|||||||
user?.name,
|
user?.name,
|
||||||
user?.excludedCommand?.some,
|
user?.excludedCommand?.some,
|
||||||
user?.excludedCommand,
|
user?.excludedCommand,
|
||||||
|
build,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { format } from "date-fns-tz";
|
import { format } from "date-fns-tz";
|
||||||
|
import Constants from "expo-constants";
|
||||||
import { useFocusEffect } from "expo-router";
|
import { useFocusEffect } from "expo-router";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
@@ -25,6 +26,7 @@ export default function ProdScanner() {
|
|||||||
const serverIp = useAppStore((s) => s.serverIp);
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
const serverPort = useAppStore((s) => s.serverPort);
|
const serverPort = useAppStore((s) => s.serverPort);
|
||||||
const [bgColor, setBGColor] = useState<string | null>(null);
|
const [bgColor, setBGColor] = useState<string | null>(null);
|
||||||
|
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||||
|
|
||||||
const handleScan = useCallback(
|
const handleScan = useCallback(
|
||||||
async (scan: ZebraScanResult) => {
|
async (scan: ZebraScanResult) => {
|
||||||
@@ -62,6 +64,7 @@ export default function ProdScanner() {
|
|||||||
: scan.data.startsWith("loc")
|
: scan.data.startsWith("loc")
|
||||||
? scan.data
|
? scan.data
|
||||||
: "0",
|
: "0",
|
||||||
|
scannerVersion: build,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await axios.post(
|
await axios.post(
|
||||||
@@ -112,7 +115,7 @@ export default function ProdScanner() {
|
|||||||
setTagScans([]);
|
setTagScans([]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[scannerIdFromStore, serverIp, serverPort, setLastScan],
|
[scannerIdFromStore, serverIp, serverPort, setLastScan, build],
|
||||||
);
|
);
|
||||||
|
|
||||||
const clearScans = () => {
|
const clearScans = () => {
|
||||||
|
|||||||
1
migrations/0052_numerous_wasp.sql
Normal file
1
migrations/0052_numerous_wasp.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "scan_log" ADD COLUMN "scanner_version" text DEFAULT '0';
|
||||||
2367
migrations/meta/0052_snapshot.json
Normal file
2367
migrations/meta/0052_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -365,6 +365,13 @@
|
|||||||
"when": 1778525497824,
|
"when": 1778525497824,
|
||||||
"tag": "0051_sad_war_machine",
|
"tag": "0051_sad_war_machine",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 52,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1778533475205,
|
||||||
|
"tag": "0052_numerous_wasp",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user