рейтинг
This commit is contained in:
14
index.js
14
index.js
@ -340,6 +340,11 @@ io.on('connection', function(socket)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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';
|
const action = isGood ? 'good' : 'bad';
|
||||||
socketMysql.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
socketMysql.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
||||||
if(!result) {
|
if(!result) {
|
||||||
@ -349,11 +354,20 @@ io.on('connection', function(socket)
|
|||||||
if(!result) {
|
if(!result) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
if(isGood) {
|
||||||
|
good++;
|
||||||
|
} else {
|
||||||
|
bad++;
|
||||||
|
}
|
||||||
|
io.sockets.emit('vote', {
|
||||||
|
hash, good, bad
|
||||||
|
});
|
||||||
callback(true)
|
callback(true)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let undoneQueries = 0;
|
let undoneQueries = 0;
|
||||||
|
@ -245,7 +245,8 @@ let XXX_BLOCK_WORDS = ['incestcash', 'asacp', 'xondemand', 'yankscash', 'klixxx'
|
|||||||
'stripping', 'swapping', 'thong', 'topless', 'toying',
|
'stripping', 'swapping', 'thong', 'topless', 'toying',
|
||||||
'trix', 'undressing', 'uniform', 'whipcream', 'brazzers', 'порно',
|
'trix', 'undressing', 'uniform', 'whipcream', 'brazzers', 'порно',
|
||||||
'порн', 'лесб', 'гей', 'геи', 'прон', 'catgoddess', 'gracel', 'fatman', 'falko', 'pthc',
|
'порн', 'лесб', 'гей', 'геи', 'прон', '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;
|
module.exports = XXX_BLOCK_WORDS;
|
||||||
|
@ -251,7 +251,7 @@ const detectSubCategory = (torrent, files, typesPriority, contentType) => {
|
|||||||
let name = torrent.name.toLowerCase()
|
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);
|
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;
|
let current = 0;
|
||||||
function func(index) {
|
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 records = torrents.length;
|
||||||
let next = index + records;
|
let next = index + records;
|
||||||
if(records == 0)
|
if(records == 0)
|
||||||
|
@ -16,6 +16,8 @@ import NoImage from './images/no-image-icon.png'
|
|||||||
|
|
||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||||
|
let rating = require('../lib/rating');
|
||||||
|
import LinearProgress from 'material-ui/LinearProgress';
|
||||||
|
|
||||||
let buildFilesTree = (filesList) => {
|
let buildFilesTree = (filesList) => {
|
||||||
let rootTree = {
|
let rootTree = {
|
||||||
@ -207,12 +209,27 @@ export default class TorrentPage extends Page {
|
|||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
window.torrentSocket.on('trackerTorrentUpdate', this.trackerUpdate);
|
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() {
|
componentWillUnmount() {
|
||||||
if(this.filesUpdated)
|
if(this.filesUpdated)
|
||||||
window.torrentSocket.off('filesReady', this.filesUpdated);
|
window.torrentSocket.off('filesReady', this.filesUpdated);
|
||||||
if(this.trackerUpdate)
|
if(this.trackerUpdate)
|
||||||
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
||||||
|
if(this.onVote)
|
||||||
|
window.torrentSocket.off('vote', this.onVote);
|
||||||
if(this.torrent && this.torrent.contentCategory == 'xxx') {
|
if(this.torrent && this.torrent.contentCategory == 'xxx') {
|
||||||
this.removeMetaTag('robots');
|
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 (
|
return (
|
||||||
<div className="w100p">
|
<div className="w100p">
|
||||||
{
|
{
|
||||||
@ -338,6 +360,23 @@ export default class TorrentPage extends Page {
|
|||||||
<div>voting...</div>
|
<div>voting...</div>
|
||||||
:
|
:
|
||||||
<div>Thank you for 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>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user