Skip to content

Commit

Permalink
Changed Mysql Plugin to monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
bgelatti committed Oct 16, 2024
1 parent 367cd7a commit bfffd70
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 48 deletions.
149 changes: 111 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/mysql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"knex": "3.1.0",
"mysql": "^2.18.1"
"mysql2": "3.11.3"
},
"devDependencies": {
"@types/mysql": "2.15.26"
Expand Down
4 changes: 2 additions & 2 deletions plugins/mysql/src/Database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const deviceDB = {} as IDatabaseConnection;

const migrationConfig: Knex.MigratorConfig = {
tableName: "migrations",
directory: path.join(dirname__, "Migrations"),
directory: path.join(dirname__, "..", "Migrations"),
// ! FIX Error: The migration directory is corrupt, the following files are missing:
disableMigrationsListValidation: true,
};
Expand All @@ -34,7 +34,7 @@ function createConnection(
options?: IConnectionOptions,
): Knex {
return knex({
client: "mysql",
client: "mysql2",
connection: {
charset: "utf8",
timezone: "utc",
Expand Down
1 change: 1 addition & 0 deletions plugins/mysql/src/Helpers/DeviceDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function getDeviceConnection(id: TGenericID, type: TDeviceType) {
table.index(["time"]);
table.index(["group"]);
table.index(["created_at"]);
table.string("serie", 100);
});
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Action/getActionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function getActionInfo(actionID: TGenericID): Promise<IAction | null> {
response.active = Boolean(response.active);
response.lock = Boolean(response.lock);
response.created_at = new Date(response.created_at);
response.tags = JSON.parse(response.tags);
response.tags = JSON.parse(JSON.stringify(response.tags));

if (response.action) {
response.action = JSON.parse(response.action);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Action/getActionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function getActionList(
item.lock = Boolean(item.lock);
}
if (item.tags) {
item.tags = JSON.parse(item.tags);
item.tags = JSON.parse(JSON.stringify(item.tags));
}
if (item.action) {
item.action = JSON.parse(item.action);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Analysis/getAnalysisInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function getAnalysisInfo(
if (response) {
response.active = Boolean(response.active);
response.created_at = new Date(response.created_at);
response.tags = JSON.parse(response.tags);
response.tags = JSON.parse(JSON.stringify(response.tags));

if (response.variables) {
response.variables = JSON.parse(response.variables);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Analysis/getAnalysisList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function getAnalysisList(
item.active = Boolean(item.active);
}
if (item.tags) {
item.tags = JSON.parse(item.tags);
item.tags = JSON.parse(JSON.stringify(item.tags));
}
if (item.variables) {
item.variables = JSON.parse(item.variables);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Device/getDeviceInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getDeviceInfo(deviceID: TGenericID): Promise<IDevice | null> {
if (response) {
response.active = Boolean(response.active);
response.created_at = new Date(response.created_at);
response.tags = JSON.parse(response.tags);
response.tags = JSON.parse(JSON.stringify(response.tags));

if (response.last_input) {
response.last_input = new Date(response.last_input);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Device/getDeviceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function getDeviceList(
item.active = Boolean(item.active);
}
if (item.tags) {
item.tags = JSON.parse(item.tags);
item.tags = JSON.parse(JSON.stringify(item.tags));
}
if (item.encoder_stack) {
item.encoder_stack = JSON.parse(item.encoder_stack);
Expand Down
2 changes: 1 addition & 1 deletion plugins/mysql/src/Providers/Tag/getTagKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function getTagKeys(type: TDatabaseGetTagKeysType): Promise<string[]> {
const keys: string[] = [];

for (const item of response) {
const tags = JSON.parse(item.tags) as ITag[];
const tags = JSON.parse(JSON.stringify(item.tags)) as ITag[];
for (const tag of tags) {
if (!keys.includes(tag.key)) {
keys.push(tag.key);
Expand Down

0 comments on commit bfffd70

Please sign in to comment.