fix #1922 add user info
This commit is contained in:
parent
c33f7c242c
commit
cb854feadb
8 changed files with 65 additions and 2 deletions
|
@ -52,6 +52,8 @@ public class SearchLogPager implements Serializable {
|
|||
|
||||
public static final String LOG_TYPE_FAVORITE_COUNT = "favorite_count_agg";
|
||||
|
||||
public static final String LOG_TYPE_USERINFO = "user_info";
|
||||
|
||||
public static final int DEFAULT_PAGE_SIZE = 20;
|
||||
|
||||
public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
|
||||
|
|
|
@ -37,12 +37,15 @@ import org.codelibs.fess.es.log.allcommon.EsPagingResultBean;
|
|||
import org.codelibs.fess.es.log.cbean.ClickLogCB;
|
||||
import org.codelibs.fess.es.log.cbean.FavoriteLogCB;
|
||||
import org.codelibs.fess.es.log.cbean.SearchLogCB;
|
||||
import org.codelibs.fess.es.log.cbean.UserInfoCB;
|
||||
import org.codelibs.fess.es.log.exbhv.ClickLogBhv;
|
||||
import org.codelibs.fess.es.log.exbhv.FavoriteLogBhv;
|
||||
import org.codelibs.fess.es.log.exbhv.SearchLogBhv;
|
||||
import org.codelibs.fess.es.log.exbhv.UserInfoBhv;
|
||||
import org.codelibs.fess.es.log.exentity.ClickLog;
|
||||
import org.codelibs.fess.es.log.exentity.FavoriteLog;
|
||||
import org.codelibs.fess.es.log.exentity.SearchLog;
|
||||
import org.codelibs.fess.es.log.exentity.UserInfo;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
|
@ -81,6 +84,9 @@ public class SearchLogService {
|
|||
@Resource
|
||||
private FavoriteLogBhv favoriteLogBhv;
|
||||
|
||||
@Resource
|
||||
private UserInfoBhv userInfoBhv;
|
||||
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
|
@ -95,7 +101,13 @@ public class SearchLogService {
|
|||
|
||||
public List<?> getSearchLogList(final SearchLogPager pager) {
|
||||
final EsPagingResultBean<?> list;
|
||||
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(pager.logType)) {
|
||||
if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(pager.logType)) {
|
||||
list = (EsPagingResultBean<?>) userInfoBhv.selectPage(cb -> {
|
||||
cb.paging(pager.getPageSize(), pager.getCurrentPageNumber());
|
||||
cb.query().addOrderBy_UpdatedAt_Desc();
|
||||
createUserInfoCondition(pager, cb);
|
||||
});
|
||||
} else if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(pager.logType)) {
|
||||
list = (EsPagingResultBean<?>) clickLogBhv.selectPage(cb -> {
|
||||
cb.paging(pager.getPageSize(), pager.getCurrentPageNumber());
|
||||
cb.query().addOrderBy_RequestedAt_Desc();
|
||||
|
@ -393,6 +405,28 @@ public class SearchLogService {
|
|||
}
|
||||
}
|
||||
|
||||
private void createUserInfoCondition(final SearchLogPager pager, final UserInfoCB cb) {
|
||||
if (StringUtil.isNotBlank(pager.userSessionId)) {
|
||||
cb.query().setId_Equal(pager.userSessionId);
|
||||
}
|
||||
if (StringUtil.isNotBlank(pager.requestedTimeRange)) {
|
||||
final String[] values = pager.requestedTimeRange.split(" - ");
|
||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
try {
|
||||
if (values.length > 0) {
|
||||
cb.query().setUpdatedAt_GreaterEqual(LocalDateTime.parse(values[0], formatter));
|
||||
}
|
||||
if (values.length > 1) {
|
||||
cb.query().setUpdatedAt_LessEqual(LocalDateTime.parse(values[1], formatter));
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to parse " + pager.requestedTimeRange, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createClickLogCondition(final SearchLogPager pager, final ClickLogCB cb) {
|
||||
if (StringUtil.isNotBlank(pager.queryId)) {
|
||||
cb.query().setQueryId_Term(pager.queryId);
|
||||
|
@ -427,13 +461,23 @@ public class SearchLogService {
|
|||
return clickLogBhv.selectByPK(id);
|
||||
} else if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(logType)) {
|
||||
return favoriteLogBhv.selectByPK(id);
|
||||
} else if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
|
||||
return userInfoBhv.selectByPK(id);
|
||||
} else {
|
||||
return searchLogBhv.selectByPK(id);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getSearchLogMap(final String logType, final String id) {
|
||||
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(logType)) {
|
||||
if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
|
||||
return userInfoBhv.selectByPK(id).map(e -> {
|
||||
final Map<String, String> params = new LinkedHashMap<>();
|
||||
params.put("User Info ID", e.getId());
|
||||
params.put("Created Time", FessFunctions.formatDate(e.getCreatedAt()));
|
||||
params.put("Updated Time", FessFunctions.formatDate(e.getUpdatedAt()));
|
||||
return params;
|
||||
}).get();
|
||||
} else if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(logType)) {
|
||||
return clickLogBhv.selectByPK(id).map(e -> {
|
||||
final Map<String, String> params = new LinkedHashMap<>();
|
||||
params.put("ID", e.getId());
|
||||
|
@ -497,6 +541,8 @@ public class SearchLogService {
|
|||
clickLogBhv.delete((ClickLog) e);
|
||||
} else if (e instanceof FavoriteLog) {
|
||||
favoriteLogBhv.delete((FavoriteLog) e);
|
||||
} else if (e instanceof UserInfo) {
|
||||
userInfoBhv.delete((UserInfo) e);
|
||||
} else if (e instanceof SearchLog) {
|
||||
searchLogBhv.delete((SearchLog) e);
|
||||
} else {
|
||||
|
|
|
@ -48,6 +48,14 @@ public class UserInfo extends BsUserInfo {
|
|||
asDocMeta().version(version);
|
||||
}
|
||||
|
||||
public String getLogMessage() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public LocalDateTime getRequestedAt() {
|
||||
return getUpdatedAt();
|
||||
}
|
||||
|
||||
public void addField(final String key, final Object value) {
|
||||
fields.put(key, value);
|
||||
}
|
||||
|
|
|
@ -2841,6 +2841,9 @@ public class FessLabels extends UserMessages {
|
|||
/** The key of the message: Favorite Log */
|
||||
public static final String LABELS_searchlog_log_type_favorite = "{labels.searchlog_log_type_favorite}";
|
||||
|
||||
/** The key of the message: User Information */
|
||||
public static final String LABELS_searchlog_log_type_user_info = "{labels.searchlog_log_type_user_info}";
|
||||
|
||||
/** The key of the message: Keywords */
|
||||
public static final String LABELS_searchlog_log_type_search_keyword = "{labels.searchlog_log_type_search_keyword}";
|
||||
|
||||
|
|
|
@ -938,6 +938,7 @@ labels.searchlog_log_type=Log Type
|
|||
labels.searchlog_log_type_search=Search Log
|
||||
labels.searchlog_log_type_click=Click Log
|
||||
labels.searchlog_log_type_favorite=Favorite Log
|
||||
labels.searchlog_log_type_user_info=User Information
|
||||
labels.searchlog_log_type_search_keyword=Keywords
|
||||
labels.searchlog_log_type_search_zerohit=Zero Hits
|
||||
labels.searchlog_log_type_search_zeroclick=Zero Clicks
|
||||
|
|
|
@ -938,6 +938,7 @@ labels.searchlog_log_type=Log Type
|
|||
labels.searchlog_log_type_search=Search Log
|
||||
labels.searchlog_log_type_click=Click Log
|
||||
labels.searchlog_log_type_favorite=Favorite Log
|
||||
labels.searchlog_log_type_user_info=User Information
|
||||
labels.searchlog_log_type_search_keyword=Keywords
|
||||
labels.searchlog_log_type_search_zerohit=Zero Hits
|
||||
labels.searchlog_log_type_search_zeroclick=Zero Clicks
|
||||
|
|
|
@ -938,6 +938,7 @@ labels.searchlog_log_type=ログ種別
|
|||
labels.searchlog_log_type_search=検索ログ
|
||||
labels.searchlog_log_type_click=クリックログ
|
||||
labels.searchlog_log_type_favorite=お気に入りログ
|
||||
labels.searchlog_log_type_user_info=ユーザーログ
|
||||
labels.searchlog_log_type_search_keyword=キーワード数
|
||||
labels.searchlog_log_type_search_zerohit=ゼロ件ヒット数
|
||||
labels.searchlog_log_type_search_zeroclick=ゼロ件クリック数
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
styleClass="form-control">
|
||||
<la:option value="search"><la:message key="labels.searchlog_log_type_search" /></la:option>
|
||||
<la:option value="click"><la:message key="labels.searchlog_log_type_click" /></la:option>
|
||||
<la:option value="user_info"><la:message key="labels.searchlog_log_type_user_info" /></la:option>
|
||||
<la:option value="favorite"><la:message key="labels.searchlog_log_type_favorite" /></la:option>
|
||||
<la:option value="search_keyword_agg"><la:message key="labels.searchlog_log_type_search_keyword" /></la:option>
|
||||
<la:option value="search_zerohit_agg"><la:message key="labels.searchlog_log_type_search_zerohit" /></la:option>
|
||||
|
|
Loading…
Add table
Reference in a new issue