Skip to content

test test#15

Open
Dimus99 wants to merge 55 commits intofirstfrom
test
Open

test test#15
Dimus99 wants to merge 55 commits intofirstfrom
test

Conversation

@Dimus99
Copy link
Copy Markdown
Owner

@Dimus99 Dimus99 commented Jan 5, 2021

No description provided.

Liza148 and others added 30 commits December 9, 2020 23:41
first commit init telegram bot
add GitHub and NetAngels Interaction
тест для реализации скачивания проекта
database improvements
интеграция бота с бд
интеграция бота с бд
# Conflicts:
#	src/main/java/DataBase.java
#	src/main/java/lib/users.db
интеграция бота с бд
cudatuda and others added 25 commits December 17, 2020 20:19
реализация ssh соединения
getLoginAndPassword по токену и id VM, можно получить список вм, поднимать/опускать машины
NETANGELS API - в процессе, готовые функции -
@Dimus99 Dimus99 changed the base branch from main to first January 5, 2021 11:47

//Конструктор с подключением к бд
//В переменной path должно находится расположние файла с бд (имя файла и самой таблицы должны сопадать)
public DataBase(String path) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, было бы лучше принимать в аргументах и путь и имя базы данных. Тогда не придётся сплитить строку и что-то там доставать.



//Конструктор с подключением к бд
//В переменной path должно находится расположние файла с бд (имя файла и самой таблицы должны сопадать)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может не таблицы, а базы данных?

}

// Добавляем запись в бд
// Этот же метод используется для изменения уже существующих данных
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не кажется хорошим идея использовать один и тот же метод и для добавления и для изменения данных. А это это логика даже в названии метода не прослеживается.

// Этот же метод используется для изменения уже существующих данных
public void addData(String id, String token) throws SQLException {
// Создаем ввод команды SQLite
String query =
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я не помню, есть ли такая возможность в котлине, но может лучше использовать интерполяцию строк?

try {
Statement statement = conn.createStatement();
statement.executeUpdate(query);
} catch (Exception e)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут же может произойти какое-то исключение не связанное с тем, что такой id уже существует. В таком случае выполнение блока finally может привести ещё к какой-то ошибке. Тут нужно использовать сначала проверку на одно конкретное исключение существования id, а потом проверять отдельно на прочие исключения.

val pullNumber = urlSplit[6]
var directoryForGitProject = "./gitCopies"
val command1 = "git clone $urlProject ${urlSplit[3]}_${urlSplit[6]}"
val command2 = "git pull origin pull/$pullNumber/head"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pullCommand

data = mapOf("api_key" to apiKey)
)
val obj : JSONObject = response.jsonObject
print(obj)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком много отладочных принтов.

channel.connect();
int readByte = commandOutput.read();

while(readByte != 0xffffffff)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может лучше стоповый байт убрать в константу?

return getInlineKeyboard(machinesList, ids)
}

private fun addToDataBase(id: String, token: String)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем эта обёртка для метода, который работает с базой данных?

} No newline at end of file
}

private fun manageActionVDS(bot: Bot, update: Update) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь и ниже идут методы, которы, как по мне, не очень связаны с логикой самого бота. Их бы лучше вынести в какой-нибудь отдельный класс.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants