mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
Merge pull request #90 from SyncrowIOT/change-start-time-device-log
Update Device Log Retrieval Logic and Interface
This commit is contained in:
@ -66,7 +66,7 @@ export interface updateDeviceFirmwareInterface {
|
||||
}
|
||||
export interface getDeviceLogsInterface {
|
||||
data: [];
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
deviceUuid?: string;
|
||||
}
|
||||
|
@ -721,18 +721,19 @@ export class DeviceService {
|
||||
): Promise<getDeviceLogsInterface> {
|
||||
try {
|
||||
const now = Date.now();
|
||||
const twoWeeksAgo = now - 14 * 24 * 60 * 60 * 1000;
|
||||
const path = `/v2.0/cloud/thing/${deviceId}/report-logs?start_time=${twoWeeksAgo}&end_time=${now}&codes=${code}&size=50`;
|
||||
const oneHourAgo = now - 1 * 60 * 60 * 1000;
|
||||
const path = `/v2.0/cloud/thing/${deviceId}/report-logs?start_time=${oneHourAgo}&end_time=${now}&codes=${code}&size=50`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'GET',
|
||||
path,
|
||||
});
|
||||
// Convert keys to camel case
|
||||
const camelCaseResponse = convertKeysToCamelCase(response);
|
||||
const logs = camelCaseResponse.result.logs ?? [];
|
||||
return {
|
||||
startTime: twoWeeksAgo.toString(),
|
||||
endTime: now.toString(),
|
||||
data: camelCaseResponse.result.logs,
|
||||
startTime: oneHourAgo,
|
||||
endTime: now,
|
||||
data: logs,
|
||||
} as getDeviceLogsInterface;
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
|
Reference in New Issue
Block a user