Skip to content

Commit

Permalink
regenerate keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
YanshuoH committed Jun 24, 2014
1 parent 2b6f7d4 commit 5f06612
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module.exports = function (app, passport, config) {
app.put('/admin/actortype', admin.editActorType);
app.delete('/admin/classification/delete/:classId', admin.deleteClassification);
app.delete('/admin/actortype/delete/:actorId', admin.deleteActorType);
// update all tickets
app.get('/admin/tickets/update', admin.ticketUpdate);

/*
* User routes
Expand Down
16 changes: 16 additions & 0 deletions controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
var utils = require('../lib/utils');

var mongoose = require('mongoose');
var NeedModel = mongoose.model('NeedModel');
var OfferModel = mongoose.model('OfferModel');
var ClassificationModel = mongoose.model('ClassificationModel');
var ActorTypeModel = mongoose.model('ActorTypeModel');

Expand Down Expand Up @@ -101,3 +103,17 @@ exports.deleteActorType = function(req, res) {
});
});
}

exports.ticketUpdate = function(req, res) {
NeedModel.list({}, function(err, need_list) {
for (var index=0; index<need_list.length; index++) {
need_list[index].save();
}
});
OfferModel.list({}, function(err, offer_list) {
for (var index=0; index<offer_list.length; index++) {
offer_list[index].save();
}
});
return res.json({statuts: 'OK'});
}
8 changes: 6 additions & 2 deletions controllers/matchs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ exports.confirm = function(req, res) {
callback(null, source_ticket, target_ticket);
});
},
function(source_ticket, target_ticket, callback) {
return res.redirect('/' + req.body.source_type + '/' + req.body.source_id.toString());
callback(null, source_ticket, target_ticket);
},
// update matching results
function(source_ticket, target_ticket, callback) {
MatchingModel.retrieveByTicketId(source_ticket._id.toString(), function(err, source_matching) {
Expand Down Expand Up @@ -151,7 +155,7 @@ exports.confirm = function(req, res) {
});
}
], function(err, source_ticket, target_ticket) {
return res.redirect('/' + req.body.source_type + '/' + req.body.source_id.toString());
console.log('new matching updated');
});
}

Expand Down Expand Up @@ -183,7 +187,7 @@ exports.matching_update = function(req, res) {
});
}
});
res.redirect('/');
return res.redirect('/');
}

exports.searching = function(req, res) {
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ exports.computekeywords = function computekeywords(text, keywords, score) {
text = this.sanizateText(text);
text_arr = text.split(' ');
for (var index=0; index<text_arr.length; index++) {
if (text_arr[index].length === 1 || text_arr[index].length === 0) {
continue;
}
if (this.worthlesswords.indexOf(text_arr[index]) < 0) {
var position = this.checkExisting(text_arr[index], keywords, 'word');
// console.log(position);
Expand Down

0 comments on commit 5f06612

Please sign in to comment.