Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subcribe #41

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Subcribe #41

wants to merge 7 commits into from

Conversation

St1lk3r
Copy link
Contributor

@St1lk3r St1lk3r commented Sep 1, 2024

Fixed one bug from Timur
Added new handler - subscribe
Added tests to it

"INSERT INTO follows(folowee_id,folower_id) VALUES($1,$2)",
user_id,user_authorized_id);

return "Subcribed";
Copy link
Contributor

Choose a reason for hiding this comment

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

Не уверен, что можно просто текст возвращать. В пост запросе сделать пост нужно было что-то осмысленное возвращать (json), думаю, что тут тоже.

Copy link
Contributor

Choose a reason for hiding this comment

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

Кажется здесь лучше вообще ничего не возращать, код 200 о всем говорит

@@ -1,3 +1,4 @@
#include <api/v1/users/subscribe/subscribe.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

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

Эту строчку убираем, повтор 17 строчки

Copy link
Contributor

Choose a reason for hiding this comment

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

Нет проверки подписки на несуществующего пользователя (корректный uuid, которого нет в бд юзерс)


from utils.error_strings import *

# No test for absent id
Copy link
Contributor

Choose a reason for hiding this comment

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

либо делай, либо убирай комментарий

@terebellum
Copy link
Contributor

не забывай про make format!!!

И у тебя тесты не проходят из-за стиля питоновского кода

Comment on lines +22 to +26
bool Is_user_exists(const boost::uuids::uuid& user_id,const userver::storages::postgres::ClusterPtr& pg_cluster_) {
auto user_exists = pg_cluster_->Execute(userver::storages::postgres::ClusterHostType::kMaster,
"SELECT name FROM users WHERE id = $1", user_id);
return !user_exists.IsEmpty();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Что это за стиль названия функции? Все функции до этого момента мы вроде в CamelCase называли

Comment on lines +50 to +52
if(user_authorized_id == user_id) {
throw errors::ValidationException("user","Can not subcribe to yourself");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Проблема не с валидацией, это логическая ошибка, тут другое должно быть

Comment on lines +53 to +58
if(!Is_user_exists(user_authorized_id,pg_cluster_)) {
throw errors::NotFoundException("user", "User with this id not found");
}
if(!Is_user_exists(user_id,pg_cluster_)) {
throw errors::NotFoundException("user", "User with this id not found");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

pg_cluster_ лучше первым аргументом

"INSERT INTO follows(folowee_id,folower_id) VALUES($1,$2)",
user_id,user_authorized_id);

return "Subcribed";
Copy link
Contributor

Choose a reason for hiding this comment

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

Кажется здесь лучше вообще ничего не возращать, код 200 о всем говорит

@terebellum terebellum linked an issue Sep 3, 2024 that may be closed by this pull request
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.

Subscribe handle
3 participants