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 {
let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss');
let filter = {
limit: 50,
attributes: [[sequelize.literal('distinct `key_word`'), 'key_word']],
attributes: ['key_word'],
where: {
state: 1,
user_id: ctx.userId,
created_at: { $gt: endDate }
}
},
order: [['created_at', 'desc']],
}
if (type) {
filter.where.house_style = type;
}
let searchHistoryList = await ctx.realestateModel.SearchHistory.findAll(filter);
let list = searchHistoryList.map(v => { return v.key_word });
ctx.logger.info(list);
let list = [];
if (searchHistoryList.length > 0) {
for (let i in searchHistoryList) {
if (list.indexOf(searchHistoryList[i].key_word) === -1) {
list.push(searchHistoryList[i].key_word);
}
}
}
ret = {
results: list,
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