Repository: louislam/uptime-kuma
File: server/server.js (JavaScript)

Code before:

                            monitor.accepted_statuscodes_json = JSON.stringify(monitor.accepted_statuscodes);
                            delete monitor.accepted_statuscodes;

                            bean.import(monitor)
                            bean.user_id = socket.userID
                            await R.store(bean)

                            if (backupData.version.includes("1.7")) {
                                if (monitorListData[i].tags.length >= 1) {
                                    for (let o = 0; o < monitorListData[i].tags.length; o++) {

                                        let tag = await R.findOne("tag", " name = ?", [
                                            monitorListData[i].tags[o].name,
                                        ])

                                        if (! tag) {
                                            let beanTag = R.dispense("tag")
                                            beanTag.name = monitorListData[i].tags[o].name
                                            beanTag.color = monitorListData[i].tags[o].color
                                            await R.store(beanTag)

                                            var tagId = beanTag.id
                                        } else {
                                            var tagId = tag.id
                                        }

                                        await R.exec("INSERT INTO monitor_tag (tag_id, monitor_id, value) VALUES (?, ?, ?)", [
                                            tagId,
                                            bean.id,
                                            monitorListData[i].tags[o].value,
                                        ])
                                    }
                                }
                            }

                            await updateMonitorNotification(bean.id, notificationIDList)

                            if (monitorListData[i].active == 1) {
                                await startMonitor(socket.userID, bean.id);
                            } else {
                                await pauseMonitor(socket.userID, bean.id);
                            }

                        }
                    }

                    await sendNotificationList(socket)
                    await sendMonitorList(socket);
                }


Review comment (suggestion):
```suggestion
                                        let tagId = tag.id

                                        if (! tag) {
                                            let beanTag = R.dispense("tag")
                                            beanTag.name = monitorListData[i].tags[o].name
                                            beanTag.color = monitorListData[i].tags[o].color
                                            await R.store(beanTag)

                                            tagId = beanTag.id
                                        }
```

Code after:
                            let retryInterval = 0;

                            /*
                            Only replace the default value with the backup file data for the specific version, where it appears the first time
                            More information about that where "let version" will be defined
                            */
                            if (version17x) {
                                retryInterval = monitorListData[i].retryInterval;
                            }

                            // --- End ---

                            let monitor = {
                                // Define the new variable from earlier here
                                name: monitorListData[i].name,
                                type: monitorListData[i].type,
                                url: monitorListData[i].url,
                                interval: monitorListData[i].interval,
                                retryInterval: retryInterval,
                                hostname: monitorListData[i].hostname,
                                maxretries: monitorListData[i].maxretries,
                                port: monitorListData[i].port,
                                keyword: monitorListData[i].keyword,
                                ignoreTls: monitorListData[i].ignoreTls,
                                upsideDown: monitorListData[i].upsideDown,
                                maxredirects: monitorListData[i].maxredirects,
                                accepted_statuscodes: monitorListData[i].accepted_statuscodes,
                                dns_resolve_type: monitorListData[i].dns_resolve_type,
                                dns_resolve_server: monitorListData[i].dns_resolve_server,
                                notificationIDList: {},
                            };

                            let bean = R.dispense("monitor");

                            let notificationIDList = monitor.notificationIDList;
                            delete monitor.notificationIDList;

                            monitor.accepted_statuscodes_json = JSON.stringify(monitor.accepted_statuscodes);
                            delete monitor.accepted_statuscodes;

                            bean.import(monitor);
                            bean.user_id = socket.userID;
                            await R.store(bean);

                            // Only for backup files with the version 1.7.0 or higher, since there was the tag feature implemented
                            if (version17x) {
                                // Only import if the specific monitor has tags assigned
                                if (monitorListData[i].tags.length >= 1) {
                                    for (let o = 0; o < monitorListData[i].tags.length; o++) {

                                        // Check if tag already exists and get data ->