Update lum la

This commit is contained in:
andrew.ng 2026-06-05 09:50:13 +07:00
parent 13109dc75f
commit 7cfe8a1d69
5 changed files with 10 additions and 13 deletions

View File

@ -91,6 +91,7 @@ Soi các nguy cơ:
- Redis state (`socket_state`, `station:{id}:line:{id}:history`): khi thêm field mới, `saveState` / `restoreState` có cover không.
- Idle-timeout (`setTimeoutConnect`, 8h) **và** keep-alive (`keepConnectAPC` 40s / `keepConnectStation` 120s) có được wire đầy đủ cho connection mới không (theo CLAUDE.md).
- Socket event mới: cả hai phía FE/BE có khớp tên + payload shape không.
- Ghi ngắn gọn nội dung
#### 4.3. Performance
@ -99,13 +100,7 @@ Soi các nguy cơ:
- Re-render React thừa (`App.tsx` đang dùng `lineBuffersRef` + flush 50ms — diff mới có phá vỡ pattern này không).
- Bộ nhớ giữ output dài (truncate ở `saveState` 5000 chars — diff mới có giữ thêm field nặng không).
- Setinterval/setTimeout có dồn (leak) không.
#### 4.4. Consistency
Hai gạch đầu dòng phụ:
- **Đúng `CLAUDE.md`?** Đối chiếu từng quy ước liên quan: subpath imports `#controllers/*` (không phải relative trừ file ngoài `app/`), folder names `ultils`/`untils` (không rename), VN/EN comment language giữ nguyên, hot-reload boundaries, idle/keep-alive paired, `saveState`/`restoreState` extend khi thêm state.
- **Đúng coding standard?** ESLint flat config / Prettier / TS strict / naming convention (camelCase biến, PascalCase component, `T*` prefix cho type ở FE). Đặt tên file/component có nhất quán không. Comment có ý nghĩa, không lặp lại code.
- Ghi ngắn gọn nội dung
#### 4.5. Simplicity
@ -113,6 +108,7 @@ Hai gạch đầu dòng phụ:
- Có over-engineering, abstraction sớm.
- Có thể gộp branch / sớm return để giảm nesting.
- Đề xuất cụ thể cách rút gọn (mỗi đề xuất kèm trước/sau ngắn nếu hữu ích).
- Ghi ngắn gọn nội dung
### 5. Trả về kết quả

View File

@ -142,8 +142,8 @@ export default class LogsController {
})
}
// Lấy 100 tên file đầu tiên từ danh sách lọc được
const result = files.slice(0, 100)
// Lấy 100 tên file mới nhất (cuối danh sách)
const result = files.slice(-100)
return response.ok({
status: true,

View File

@ -582,7 +582,7 @@ export default class LineConnection {
? { ...this.config.inventory, ...dataInventory, listInventory }
: { ...dataInventory, listInventory }
pid = dataInventory?.pid || ''
this.addHistory(this.config.stationId, this.config.id, {
await this.addHistory(this.config.stationId, this.config.id, {
id: this.config.id,
number: this.config.lineNumber,
stationId: this.config.stationId,
@ -655,7 +655,7 @@ export default class LineConnection {
},
data,
})
this.addHistory(
await this.addHistory(
this.config.stationId,
this.config.id,
{
@ -2616,7 +2616,7 @@ Ports Missing/Down: ${missing.length}\n\n`
console.error(`Failed to save report for SN ${reportSN}:`, err)
}
}
this.addHistory(
await this.addHistory(
this.config.stationId,
this.config.id,
{

View File

@ -37,7 +37,7 @@ const parseLog = (data: string) => {
Object.keys(currentRecord).forEach((key) => {
if (item && item[key] !== undefined) {
if (key === "pid") {
item[key] = item[key].replace("(", '').replace(")", '')
item[key] = item[key].replace(/[()]/g, '')
}
currentRecord[key] = item[key].trim()
}

View File

@ -127,6 +127,7 @@ function DrawerLogs({
}, [testLogContent]);
useEffect(() => {
if (!opened) return;
// Clear previous debounce timer
if (debounceTimerRef.current) {
clearTimeout(debounceTimerRef.current);