mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-22 20:01:48 +01:00
feat(core): add table users and torrents global update method
for some fields update with time limit
This commit is contained in:
@@ -258,6 +258,9 @@ exports.announce = function (req, res) {
|
||||
} else {
|
||||
req.torrent = t;
|
||||
|
||||
//active torrent update method to update some fields value
|
||||
t.globalUpdateMethod();
|
||||
|
||||
/*
|
||||
find myself peers
|
||||
if the peer is ghost, deleted it
|
||||
|
||||
@@ -632,6 +632,7 @@
|
||||
DETAIL: 'Detail',
|
||||
SIGNUP_DATE: 'Sign up at',
|
||||
LATEST_SIGNED_TIME: 'Latest signed at',
|
||||
LATEST_REFRESH_TIME: 'Latest refresh at',
|
||||
SIGNED_IP: 'Signed IP list',
|
||||
LEECHED_IP: 'Leeched IP list',
|
||||
BT_CLIENT: 'Leeched BT Client list'
|
||||
|
||||
@@ -632,6 +632,7 @@
|
||||
DETAIL: '详情',
|
||||
SIGNUP_DATE: '注册时间',
|
||||
LATEST_SIGNED_TIME: '最近一次登录时间',
|
||||
LATEST_REFRESH_TIME: '最近一次刷新时间',
|
||||
SIGNED_IP: '登录过网站的IP列表',
|
||||
LEECHED_IP: '下载过的IP列表',
|
||||
BT_CLIENT: '下载过的BT客户端'
|
||||
|
||||
@@ -212,6 +212,9 @@ exports.countUnread = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
//active user update method to update some fields value
|
||||
req.user.globalUpdateMethod();
|
||||
|
||||
var countFrom = function (callback) {
|
||||
Message.count({
|
||||
from_user: req.user._id,
|
||||
|
||||
@@ -194,10 +194,13 @@ var TorrentSchema = new Schema({
|
||||
orderedat: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
},
|
||||
refreshat: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Hook a pre save method
|
||||
*/
|
||||
@@ -233,6 +236,15 @@ function writeIsSaling(torrent) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* globalUpdateMethod
|
||||
*/
|
||||
TorrentSchema.methods.globalUpdateMethod = function () {
|
||||
this.update({
|
||||
$set: {refreshat: Date.now()}
|
||||
}).exec();
|
||||
};
|
||||
|
||||
TorrentSchema.index({user: -1, createdat: -1});
|
||||
TorrentSchema.index({info_hash: -1, createdat: -1});
|
||||
TorrentSchema.index({torrent_tmdb_id: -1, createdat: -1});
|
||||
|
||||
@@ -124,6 +124,9 @@
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.LATEST_SIGNED_TIME' | translate}}:</dt>
|
||||
<dd class="h-line">{{ vm.user.last_signed | date: 'yyyy-MM-dd HH:mm:ss' }}</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.LATEST_REFRESH_TIME' | translate}}:</dt>
|
||||
<dd class="h-line">{{ vm.user.refreshat | date: 'yyyy-MM-dd HH:mm:ss' }}</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.SIGNED_IP' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<div class="list-all-ips">
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.LATEST_SIGNED_TIME' | translate}}:</dt>
|
||||
<dd class="h-line">{{ vm.user.last_signed | date: 'yyyy-MM-dd HH:mm:ss' }}</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.LATEST_REFRESH_TIME' | translate}}:</dt>
|
||||
<dd class="h-line">{{ vm.user.refreshat | date: 'yyyy-MM-dd HH:mm:ss' }}</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.SIGNED_IP' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<div class="list-all-ips">
|
||||
|
||||
@@ -209,6 +209,10 @@ var UserSchema = new Schema({
|
||||
type: Date,
|
||||
default: Date.now
|
||||
},
|
||||
refreshat: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
},
|
||||
/* For reset password */
|
||||
resetPasswordToken: {
|
||||
type: String
|
||||
@@ -357,6 +361,15 @@ UserSchema.methods.addLeechedIp = function (ip) {
|
||||
}).exec();
|
||||
};
|
||||
|
||||
/**
|
||||
* globalUpdateMethod
|
||||
*/
|
||||
UserSchema.methods.globalUpdateMethod = function () {
|
||||
this.update({
|
||||
$set: {refreshat: Date.now()}
|
||||
}).exec();
|
||||
};
|
||||
|
||||
/**
|
||||
* update user last client_agent
|
||||
* @param ip
|
||||
|
||||
Reference in New Issue
Block a user