fix(test): fix test case for table deletion and optimize code

This commit is contained in:
2024-06-23 13:33:53 +02:00
parent 367bacb954
commit 84c355c499
5 changed files with 42 additions and 17 deletions

View File

@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartclickhouse',
version: '2.0.17',
version: '2.0.18',
description: 'A TypeScript-based ODM for ClickHouse databases that supports creating, managing, and querying tables with a focus on handling time-series data.'
}

View File

@ -270,6 +270,7 @@ export class TimeDataTable {
return new plugins.smartrx.rxjs.Observable((observer) => {
const pollInterval = 1000; // Poll every 1 second
let lastTimestamp: number;
let intervalId: NodeJS.Timeout;
const fetchLastEntryTimestamp = async () => {
const lastEntry = await this.smartClickHouseDbRef.clickhouseHttpClient.queryPromise(`
@ -292,13 +293,13 @@ export class TimeDataTable {
const startPolling = async () => {
await fetchLastEntryTimestamp();
const intervalId = setInterval(fetchNewEntries, pollInterval);
// Cleanup on unsubscribe
return () => clearInterval(intervalId);
intervalId = setInterval(fetchNewEntries, pollInterval);
};
startPolling().catch((err) => observer.error(err));
// Cleanup on unsubscribe
return () => clearInterval(intervalId);
});
}
}