mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-07 20:27:01 +02:00
feat(home): show albums list by push time
This commit is contained in:
@@ -169,6 +169,7 @@ exports.toggleHomeItemStatus = function (req, res) {
|
||||
var album = req.album;
|
||||
|
||||
album.isHomeStatus = !album.isHomeStatus;
|
||||
album.home_at = Date.now();
|
||||
|
||||
album.save(function (err) {
|
||||
if (err) {
|
||||
@@ -206,6 +207,8 @@ exports.list = function (req, res) {
|
||||
var isHomeStatus = undefined;
|
||||
var condition = {};
|
||||
|
||||
var sort_str = '-recommend_level -ordered_at -created_at';
|
||||
|
||||
if (req.query.type !== undefined) {
|
||||
type = req.query.type;
|
||||
}
|
||||
@@ -218,13 +221,14 @@ exports.list = function (req, res) {
|
||||
}
|
||||
if (isHomeStatus !== undefined) {
|
||||
condition.isHomeStatus = isHomeStatus;
|
||||
sort_str = '-home_at';
|
||||
}
|
||||
|
||||
mtDebug.info(condition);
|
||||
|
||||
var findQuery = function (callback) {
|
||||
Album.find(condition)
|
||||
.sort('-recommend_level -ordered_at -created_at')
|
||||
.sort(sort_str)
|
||||
.populate('torrents')
|
||||
.exec(function (err, albums) {
|
||||
if (err) {
|
||||
|
||||
@@ -51,6 +51,9 @@ var AlbumSchema = new Schema({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
home_at: {
|
||||
type: Date,
|
||||
},
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
@@ -62,5 +65,6 @@ var AlbumSchema = new Schema({
|
||||
}, {usePushEach: true});
|
||||
|
||||
AlbumSchema.index({type: 1, recommend_level: 1, ordered_at: -1, created_at: -1});
|
||||
AlbumSchema.index({isHomeStatus: 1, home_at: -1});
|
||||
|
||||
mongoose.model('Album', AlbumSchema);
|
||||
|
||||
Reference in New Issue
Block a user