From cf33e483f7e6f40e8cbbbc0118a7df70bdaf651f Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 29 Mar 2018 20:32:18 +0900 Subject: 整理した MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tools/analysis/predict-user-interst.ts | 45 ------------------------------ 1 file changed, 45 deletions(-) delete mode 100644 src/tools/analysis/predict-user-interst.ts (limited to 'src/tools/analysis/predict-user-interst.ts') diff --git a/src/tools/analysis/predict-user-interst.ts b/src/tools/analysis/predict-user-interst.ts deleted file mode 100644 index a101f2010e..0000000000 --- a/src/tools/analysis/predict-user-interst.ts +++ /dev/null @@ -1,45 +0,0 @@ -import Post from '../../server/api/models/post'; -import User from '../../server/api/models/user'; - -export async function predictOne(id) { - console.log(`predict interest of ${id} ...`); - - // TODO: repostなども含める - const recentPosts = await Post.find({ - userId: id, - category: { - $exists: true - } - }, { - sort: { - _id: -1 - }, - limit: 1000, - fields: { - _id: false, - category: true - } - }); - - const categories = {}; - - recentPosts.forEach(post => { - if (categories[post.category]) { - categories[post.category]++; - } else { - categories[post.category] = 1; - } - }); -} - -export async function predictAll() { - const allUsers = await User.find({}, { - fields: { - _id: true - } - }); - - allUsers.forEach(user => { - predictOne(user._id); - }); -} -- cgit v1.2.3-freya