} else {
trends = trendService.getCurrentTrends(domain);
}
for (Trend trend : trends) {
Tag tag = new Tag();
tag.setName(trend.getTag());
tag.setTrendingUp(trend.isTrendingUp());
tags.add(tag);
}
} else if (search != null && !search.isEmpty()) {
String prefix = search.toLowerCase();
tagNames = trendService.searchTags(domain, prefix, 5);
for (String tagName : tagNames) {
Tag tag = new Tag();
tag.setName(tagName);
tags.add(tag);
}
} else {
tagNames = userTagRepository.findTags(currentUser.getLogin());
for (String tagName : tagNames) {
Tag tag = new Tag();
tag.setName(tagName);
tags.add(tag);
}
}
for (Tag tag : tags) {
if (followedTags.contains(tag.getName())) {
tag.setFollowed(true);
}
}
return tags;
}