Skip to content

Guess Country #563

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Shkarin
Copy link
Contributor

@Shkarin Shkarin commented Apr 20, 2017

Addressed to #517

Supersede #547 (that php-coder closed accidentally)


Check before merge:

  • user without any series in collection shouldn't see suggestion
  • user with series with country should have suggestion for this country
  • user who created series with country should have suggestion for this country
  • link should look good

After merge:

  • mention in commit message why we decided to use ajax instead of doing all of this logic on the server
  • create an issue: add unit tests
  • create an issue: add integration tests
  • create an issue: implement country choosing on prototype
  • create an issue: disable country suggestion when country has been specified
  • create an issue: user who created a country but don't have series with country (or has series without country) should have suggestion for this country

@mystamps-bot
Copy link

mystamps-bot commented Apr 20, 2017

1 Message
📖 @Shkarin thank you for the PR! All quality checks have been passed! Next step is to wait when @php-coder will review this code

Generated by 🚫 Danger

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 80.964% when pulling 749861a on Shkarin:gh571_prediction_country into 0abdb81 on php-coder:master.

Copy link
Owner

@php-coder php-coder left a comment

Choose a reason for hiding this comment

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

Отлично! Мне кажется, что еще немного и можно будет мерджить!

}

Copy link
Owner

Choose a reason for hiding this comment

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

Убери этот лишний перевод строки.

@@ -35,4 +36,6 @@
List<Object[]> getStatisticsOf(Integer collectionId, String lang);
List<LinkEntityDto> findAllAsLinkEntities(String lang);
LinkEntityDto findOneAsLinkEntity(String slug, String lang);

Copy link
Owner

Choose a reason for hiding this comment

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

Убери эту пустую строку.

String.class
);

} catch (EmptyResultDataAccessException ex) {
Copy link
Owner

Choose a reason for hiding this comment

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

Переименуй ex в ignored.


$.get(suggestCountryUrl, function (slug) {
if (slug == "")
return;
Copy link
Owner

Choose a reason for hiding this comment

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

Тело if-а должно быть в {}

@@ -21,4 +21,23 @@ function initPage() {
$('.js-with-tooltip').tooltip({
'placement': 'right'
});

if (suggestCountryUrl == null) {
return;
Copy link
Owner

Choose a reason for hiding this comment

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

Вместо того, чтобы делать return в этом месте, давай изменим условие и внесем .get() внутрь условия:

if (suggestCountryUrl != null) {
    $.get() {
        ...
    }
}

Позже, мы добавим еще один блок для категории.

@@ -76,6 +76,12 @@

@Value("${country.find_country_link_info_by_slug}")
private String findCountryLinkEntityBySlugSql;

@Value("${country.find_last_country_by_id}")
private String findLastCountryByIdSql;
Copy link
Owner

Choose a reason for hiding this comment

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

findLastCountryByIdSql -> findLastCreatedByUserSql

private String findLastCountryByIdSql;

@Value("${country.find_popular_country}")
private String findPopularCountrySql;
Copy link
Owner

Choose a reason for hiding this comment

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

findPopularCountrySql -> findPopularCountryInCollectionSql



@Override
public String suggestCountryForUser(Integer userId) {
Copy link
Owner

Choose a reason for hiding this comment

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

Этот метод нужно переименовать в findLastCreatedByUser()

Copy link
Owner

Choose a reason for hiding this comment

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

P.S. И не забудь добавить автора.

findPopularCountrySql,
Collections.<String, Object>emptyMap(),
String.class
);
Copy link
Owner

Choose a reason for hiding this comment

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

Все что внутри первого catch-а нужно вынести в отдельный метод findPopularCountryInCollection()

@Override
@Transactional(readOnly = true)
@PreAuthorize(HasAuthority.CREATE_SERIES)
public String suggestCountryForUser(Integer userId) {
Copy link
Owner

Choose a reason for hiding this comment

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

Этот метод должен вызывать сначала методы дао -- сначала findLastCreatedByUser(), а потом findPopularCountryInCollection().

Собственно, в сервисах должна быть вся логика, а дао методы должны быть как атомарные действия и следовать SRP (https://ru.wikipedia.org/wiki/Принцип_единственной_ответственности).

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 22, 2017 via email

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 22, 2017 via email

@php-coder
Copy link
Owner

Нельзя переименовать так-как ignored уже объявлена

Yes, but later this code will be in a separate method, so don't forget to rename it there.

@php-coder
Copy link
Owner

#guess_country это тег. Почему мы на него навешиваем on click
событие? Только чтобы заодно весь его скрыть?

идею не понял, а как без события клик? мне нужно скрыть эту ссылку и
подставить значение

I mean that why we have "on click" handler on <small> tag? Why it's not on the <a> tag? I'm trying to understand why we're doing so in this way.

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 23, 2017 via email

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 23, 2017 via email

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 23, 2017 via email

@php-coder
Copy link
Owner

блин я не так тебя понял( можно и на тег сделать клик

Если можно, то давай так и сделаем. Это выглядит более логично.

@php-coder
Copy link
Owner

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

В series находятся все серии, которые доступны на сайте. Тебе нужны таблицы collections (которая связывает пользователя с его коллекцией) и collections_series (которая связывает коллекцию с сериями, которые в нее входят).

@php-coder
Copy link
Owner

Потому что ссылка с тегом small, становится меньше и отсюда смотрится
лучше, на мой взгляд, ее осталось выровнять по центру и будем идеально)

Кстати, да, не забудь выровнять ее.

JOIN countries c ON c.id = s.country_id \
WHERE s.created_by = :created_by \
ORDER BY s.created_at DESC\
LIMIT 1
Copy link
Owner

Choose a reason for hiding this comment

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

Отформатируй, пожалуйста, чтобы ключевые слова были справа, а остальное слева и посередине был столбец из пробелов:

  • перед JOIN-ом и LIMIT-ом нужно добавить по пробелу
  • после DESC нужно добавить пробел перед переводом строки

@php-coder
Copy link
Owner

Осталось немного:

  • исправить SQL-запрос (и соответствующий метод дао)
  • немного отформатировать другой SQL-запрос
  • отцентрировать ссылку
  • переместить идентификатор с тега small на a
  • исправить ошибки от checkstyle/pmd:
    • Добавить @SuppressWarnings для Avoid excessively long variable names like findPopularCountryInCollectionSql
    • разбить строчки с логгированием на 5 строк

Вроде бы все.

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 26, 2017 via email

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 28, 2017 via email

@php-coder
Copy link
Owner

  • разбить строчки с логгированием на 5 строк

это где?

Это предупреждения на длинные строки тут #563 (comment)

ты задачу с #547 (comment) еще не поставил? если нет я поставлю

Нет. Создай, пожалуйста.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 80.353% when pulling a5edb40 on Shkarin:gh571_prediction_country into 0abdb81 on php-coder:master.

@Shkarin
Copy link
Contributor Author

Shkarin commented Apr 29, 2017 via email

@Shkarin Shkarin force-pushed the gh571_prediction_country branch from 7ad85a9 to 90ab13d Compare April 29, 2017 21:04
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 90ab13d on Shkarin:gh571_prediction_country into ** on php-coder:master**.

@php-coder
Copy link
Owner

php-coder commented Apr 30, 2017 via email

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c6ba408 on Shkarin:gh571_prediction_country into ** on php-coder:master**.

@Shkarin Shkarin force-pushed the gh571_prediction_country branch from c6ba408 to d881843 Compare May 2, 2017 14:39
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling d881843 on Shkarin:gh571_prediction_country into ** on php-coder:master**.

@php-coder
Copy link
Owner

@Shkarin Всё, можно ревьювить или ты еще планируешь что-то доделать?

@Shkarin
Copy link
Contributor Author

Shkarin commented May 4, 2017 via email

@Shkarin
Copy link
Contributor Author

Shkarin commented May 6, 2017 via email

@php-coder
Copy link
Owner

Merged in f96d776 commit.

@php-coder
Copy link
Owner

php-coder commented May 6, 2017

Спасибо! Я добавил еще несколько мелких улучшений (можешь глянуть 7 дополнительных коммитов). Чуть позже я создам еще несколько задач, часть из которых нужно будет сделать до того как будут реализованы подсказки для категорий.

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

Successfully merging this pull request may close these issues.

4 participants