Commit e3a46d52 authored by 李尚科's avatar 李尚科
parents 61ba2d5e bd985926
Pipeline #8752 passed with stage
in 4 seconds
...@@ -45,21 +45,26 @@ class searchHistoryService extends Service { ...@@ -45,21 +45,26 @@ class searchHistoryService extends Service {
let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss'); let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss');
let filter = { let filter = {
limit: 50, limit: 50,
attributes: [[sequelize.literal('distinct `key_word`'), 'key_word']], attributes: ['key_word'],
where: { where: {
state: 1, state: 1,
user_id: ctx.userId, user_id: ctx.userId,
created_at: { $gt: endDate } created_at: { $gt: endDate }
} },
order: [['created_at', 'desc']],
} }
if (type) { if (type) {
filter.where.house_style = type; filter.where.house_style = type;
} }
let searchHistoryList = await ctx.realestateModel.SearchHistory.findAll(filter); let searchHistoryList = await ctx.realestateModel.SearchHistory.findAll(filter);
let list = searchHistoryList.map(v => { return v.key_word }); let list = [];
if (searchHistoryList.length > 0) {
ctx.logger.info(list); for (let i in searchHistoryList) {
if (list.indexOf(searchHistoryList[i].key_word) === -1) {
list.push(searchHistoryList[i].key_word);
}
}
}
ret = { ret = {
results: list, results: list,
count: list.length count: list.length
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment