mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Add linting and unused cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var db = require(pathThumbnails + "/handlers/db.js");
|
||||
|
||||
function frontpage_lists(msg, socket) {
|
||||
if (
|
||||
msg == undefined ||
|
||||
@@ -17,11 +18,15 @@ function frontpage_lists(msg, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection("frontpage_lists").find({ frontpage: true }, function(
|
||||
db.collection("frontpage_lists").find({
|
||||
frontpage: true
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
db.collection("connected_users").find({ _id: "total_users" }, function(
|
||||
db.collection("connected_users").find({
|
||||
_id: "total_users"
|
||||
}, function (
|
||||
err,
|
||||
tot
|
||||
) {
|
||||
@@ -44,16 +49,22 @@ function get_frontpage_lists(callback) {
|
||||
title: 1,
|
||||
viewers: 1,
|
||||
accessed: 1,
|
||||
pinned: { $ifNull: ["$pinned", 0] },
|
||||
pinned: {
|
||||
$ifNull: ["$pinned", 0]
|
||||
},
|
||||
description: {
|
||||
$ifNull: [
|
||||
{
|
||||
$ifNull: [{
|
||||
$cond: {
|
||||
if: {
|
||||
$or: [
|
||||
{ $eq: ["$description", ""] },
|
||||
{ $eq: ["$description", null] },
|
||||
{ $eq: ["$description", undefined] }
|
||||
$or: [{
|
||||
$eq: ["$description", ""]
|
||||
},
|
||||
{
|
||||
$eq: ["$description", null]
|
||||
},
|
||||
{
|
||||
$eq: ["$description", undefined]
|
||||
}
|
||||
]
|
||||
},
|
||||
then: "This list has no description",
|
||||
@@ -64,14 +75,18 @@ function get_frontpage_lists(callback) {
|
||||
]
|
||||
},
|
||||
thumbnail: {
|
||||
$ifNull: [
|
||||
{
|
||||
$ifNull: [{
|
||||
$cond: {
|
||||
if: {
|
||||
$or: [
|
||||
{ $eq: ["$thumbnail", ""] },
|
||||
{ $eq: ["$thumbnail", null] },
|
||||
{ $eq: ["$thumbnail", undefined] }
|
||||
$or: [{
|
||||
$eq: ["$thumbnail", ""]
|
||||
},
|
||||
{
|
||||
$eq: ["$thumbnail", null]
|
||||
},
|
||||
{
|
||||
$eq: ["$thumbnail", undefined]
|
||||
}
|
||||
]
|
||||
},
|
||||
then: {
|
||||
@@ -80,16 +95,19 @@ function get_frontpage_lists(callback) {
|
||||
else: "$thumbnail"
|
||||
}
|
||||
},
|
||||
{ $concat: ["https://img.youtube.com/vi/", "$id", "/mqdefault.jpg"] }
|
||||
{
|
||||
$concat: ["https://img.youtube.com/vi/", "$id", "/mqdefault.jpg"]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
db.collection("frontpage_lists").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
frontpage: true,
|
||||
count: { $gt: 3 }
|
||||
count: {
|
||||
$gt: 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -111,7 +129,9 @@ function get_frontpage_lists(callback) {
|
||||
|
||||
function update_frontpage(coll, id, title, thumbnail, source, callback) {
|
||||
//coll = coll.replace(/ /g,'');
|
||||
db.collection("frontpage_lists").find({ _id: coll }, function(e, doc) {
|
||||
db.collection("frontpage_lists").find({
|
||||
_id: coll
|
||||
}, function (e, doc) {
|
||||
var updateObject = {
|
||||
id: id,
|
||||
title: title,
|
||||
@@ -120,20 +140,23 @@ function update_frontpage(coll, id, title, thumbnail, source, callback) {
|
||||
if (
|
||||
doc.length > 0 &&
|
||||
((doc[0].thumbnail != "" &&
|
||||
doc[0].thumbnail != undefined &&
|
||||
(doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 ||
|
||||
doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1 ||
|
||||
doc[0].thumbnail.indexOf("https://img.youtube.com") > -1)) ||
|
||||
doc[0].thumbnail != undefined &&
|
||||
(doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 ||
|
||||
doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1 ||
|
||||
doc[0].thumbnail.indexOf("https://img.youtube.com") > -1)) ||
|
||||
(doc[0].thumbnail == "" || doc[0].thumbnail == undefined))
|
||||
) {
|
||||
updateObject.thumbnail = thumbnail;
|
||||
if (thumbnail == undefined) updateObject.thumbnail = "";
|
||||
}
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: coll },
|
||||
{ $set: updateObject },
|
||||
{ upsert: true },
|
||||
function(err, returnDocs) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: coll
|
||||
}, {
|
||||
$set: updateObject
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, returnDocs) {
|
||||
if (typeof callback == "function") callback();
|
||||
}
|
||||
);
|
||||
@@ -142,4 +165,4 @@ function update_frontpage(coll, id, title, thumbnail, source, callback) {
|
||||
|
||||
module.exports.get_frontpage_lists = get_frontpage_lists;
|
||||
module.exports.frontpage_lists = frontpage_lists;
|
||||
module.exports.update_frontpage = update_frontpage;
|
||||
module.exports.update_frontpage = update_frontpage;
|
||||
Reference in New Issue
Block a user