рейтинг
This commit is contained in:
parent
513b38b730
commit
b7cc799cb1
36
index.js
36
index.js
@ -340,17 +340,31 @@ io.on('connection', function(socket)
|
||||
return
|
||||
}
|
||||
|
||||
const action = isGood ? 'good' : 'bad';
|
||||
socketMysql.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
||||
if(!result) {
|
||||
console.error(err);
|
||||
}
|
||||
socketMysql.query('UPDATE torrents SET ' + action + ' = ' + action + ' + 1 WHERE hash = ?', hash, function(err, result) {
|
||||
if(!result) {
|
||||
console.error(err);
|
||||
}
|
||||
callback(true)
|
||||
});
|
||||
socketMysql.query('SELECT good, bad FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||
if(!rows || rows.length == 0)
|
||||
return;
|
||||
|
||||
let {good, bad} = rows[0];
|
||||
const action = isGood ? 'good' : 'bad';
|
||||
socketMysql.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
||||
if(!result) {
|
||||
console.error(err);
|
||||
}
|
||||
socketMysql.query('UPDATE torrents SET ' + action + ' = ' + action + ' + 1 WHERE hash = ?', hash, function(err, result) {
|
||||
if(!result) {
|
||||
console.error(err);
|
||||
}
|
||||
if(isGood) {
|
||||
good++;
|
||||
} else {
|
||||
bad++;
|
||||
}
|
||||
io.sockets.emit('vote', {
|
||||
hash, good, bad
|
||||
});
|
||||
callback(true)
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -245,7 +245,8 @@ let XXX_BLOCK_WORDS = ['incestcash', 'asacp', 'xondemand', 'yankscash', 'klixxx'
|
||||
'stripping', 'swapping', 'thong', 'topless', 'toying',
|
||||
'trix', 'undressing', 'uniform', 'whipcream', 'brazzers', 'порно',
|
||||
'порн', 'лесб', 'гей', 'геи', 'прон', 'catgoddess', 'gracel', 'fatman', 'falko', 'pthc',
|
||||
'ptsc', 'yukikax', 'ls-models'
|
||||
'ptsc', 'yukikax', 'ls-models', '3yo', '4yo', '5yo', '6yo', '7yo', '8yo', '9yo',
|
||||
'10yo', '11yo', '12yo', '13yo', '14yo', '15yo', '16yo'
|
||||
];
|
||||
|
||||
module.exports = XXX_BLOCK_WORDS;
|
||||
|
@ -251,7 +251,7 @@ const detectSubCategory = (torrent, files, typesPriority, contentType) => {
|
||||
let name = torrent.name.toLowerCase()
|
||||
|
||||
// блокируем порнографию
|
||||
if(contentType == ContentTypes.VIDEO || contentType == ContentTypes.PICTURES)
|
||||
if(contentType == ContentTypes.VIDEO || contentType == ContentTypes.PICTURES || contentType == ContentTypes.ARCHIVE)
|
||||
{
|
||||
blockBadName(torrent, name);
|
||||
// блокируем так по названию файлов
|
||||
|
17
lib/rating.js
Normal file
17
lib/rating.js
Normal file
@ -0,0 +1,17 @@
|
||||
function biasValuation(count, min, avrg, avrg_const)
|
||||
{
|
||||
return ((count / (count + min)) * avrg) + ((min / (min + count)) * avrg_const);
|
||||
}
|
||||
|
||||
const rating = (good, bad) => {
|
||||
if (good + bad > 0)
|
||||
{
|
||||
return biasValuation(good + bad, 9, good / (good + bad), 0.45);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = rating;
|
@ -18,7 +18,7 @@ socketMysql.connect(function(mysqlError) {
|
||||
|
||||
let current = 0;
|
||||
function func(index) {
|
||||
socketMysql.query("SELECT * FROM `torrents` WHERE (`contentType` = 'video' or contentType = 'pictures') and contentCategory IS NULL LIMIT ?, 30000", [index], function (error, torrents, fields) {
|
||||
socketMysql.query("SELECT * FROM `torrents` WHERE (`contentType` = 'video' or contentType = 'pictures' or contentType = 'archive') and contentCategory IS NULL LIMIT ?, 30000", [index], function (error, torrents, fields) {
|
||||
let records = torrents.length;
|
||||
let next = index + records;
|
||||
if(records == 0)
|
||||
|
@ -16,6 +16,8 @@ import NoImage from './images/no-image-icon.png'
|
||||
|
||||
var moment = require('moment');
|
||||
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||
let rating = require('../lib/rating');
|
||||
import LinearProgress from 'material-ui/LinearProgress';
|
||||
|
||||
let buildFilesTree = (filesList) => {
|
||||
let rootTree = {
|
||||
@ -207,12 +209,27 @@ export default class TorrentPage extends Page {
|
||||
this.forceUpdate();
|
||||
}
|
||||
window.torrentSocket.on('trackerTorrentUpdate', this.trackerUpdate);
|
||||
|
||||
this.onVote = ({hash, good, bad}) => {
|
||||
if(this.props.hash != hash)
|
||||
return;
|
||||
|
||||
if(!this.torrent)
|
||||
return;
|
||||
|
||||
this.torrent.good = good;
|
||||
this.torrent.bad = bad;
|
||||
this.forceUpdate();
|
||||
}
|
||||
window.torrentSocket.on('vote', this.onVote);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
if(this.filesUpdated)
|
||||
window.torrentSocket.off('filesReady', this.filesUpdated);
|
||||
if(this.trackerUpdate)
|
||||
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
||||
if(this.onVote)
|
||||
window.torrentSocket.off('vote', this.onVote);
|
||||
if(this.torrent && this.torrent.contentCategory == 'xxx') {
|
||||
this.removeMetaTag('robots');
|
||||
}
|
||||
@ -254,6 +271,11 @@ export default class TorrentPage extends Page {
|
||||
);
|
||||
}
|
||||
|
||||
let torrentRating;
|
||||
if(this.torrent) {
|
||||
torrentRating = Math.round(rating(this.torrent.good, this.torrent.bad) * 100);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w100p">
|
||||
{
|
||||
@ -338,6 +360,23 @@ export default class TorrentPage extends Page {
|
||||
<div>voting...</div>
|
||||
:
|
||||
<div>Thank you for voting!</div>
|
||||
}
|
||||
{
|
||||
this.torrent.good > 0 || this.torrent.bad > 0
|
||||
?
|
||||
<div className='w100p' style={{padding: '7px 35px', marginTop: '10px'}}>
|
||||
<LinearProgress
|
||||
mode="determinate"
|
||||
value={torrentRating}
|
||||
color={torrentRating >= 50 ? '#00E676' : '#FF3D00'}
|
||||
style={{
|
||||
height: '5px',
|
||||
}}
|
||||
/>
|
||||
<div className='row center pad0-75 fs0-85' style={{color: torrentRating >= 50 ? '#00E676' : '#FF3D00'}}>Torrent rating: {torrentRating}%</div>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user