Skip to content

Commit

Permalink
Merge pull request #463 from mayeaux/fix-ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
mayeaux authored Sep 23, 2022
2 parents ca56174 + 3b9efa2 commit bb03f55
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 15,810 deletions.
8 changes: 4 additions & 4 deletions caching/cachePopularUploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function getPopularUploads(){

if(logCaching == 'true'){
c.l('Beginning caching popular uploads, getting popular uploads from db');
console.log(moment(new Date).format('hh:mm:ss A'))
console.log(moment(new Date).format('hh:mm:ss A'));
}

// TODO: have to have a job to update upload's view amounts
Expand Down Expand Up @@ -63,17 +63,17 @@ async function setPopularUploads(){

let formattedPopularUploads = [];

console.log(moment(new Date).format('hh:mm:ss A'))
console.log(moment(new Date).format('hh:mm:ss A'));

for(const upload of popularUploads){
const uploadViews = await View.find({ upload, validity: 'real' }).select('createdAt')
const uploadViews = await View.find({ upload, validity: 'real' }).select('createdAt');

formattedPopularUploads.push(calculateViewsByPeriod(upload, uploadViews));
}

if(logCaching == 'true'){
c.l('Popular uploads have been calculated according to view periods');
console.log(moment(new Date).format('hh:mm:ss A'))
console.log(moment(new Date).format('hh:mm:ss A'));
}

// build json objects representing uploads
Expand Down
6 changes: 3 additions & 3 deletions caching/cacheRecentUploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const logCaching = process.env.LOG_CACHING;
async function getRecentUploads(){

if(logCaching == 'true'){
console.log(`Beginning running recent uploads`);
console.log('Beginning running recent uploads');

}

Expand Down Expand Up @@ -67,8 +67,8 @@ async function getRecentUploads(){
async function setRecentUploads(){
let recentUploads = await getRecentUploads();

console.log(`Calculating view amounts`);
console.log(moment(new Date).format('hh:mm:ss A'))
console.log('Calculating view amounts');
console.log(moment(new Date).format('hh:mm:ss A'));

// calculate view periods for each upload
recentUploads = await Promise.all(recentUploads.map(async function(upload){
Expand Down
4 changes: 2 additions & 2 deletions caching/calculateUploadViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function calculateViewAmounts(){

if(logCaching == 'true'){
c.l('Calculating view amounts for particular videos');
console.log(moment(new Date).format('hh:mm:ss A'))
console.log(moment(new Date).format('hh:mm:ss A'));
}

// TODO: have to have a job to update upload's view amounts
Expand All @@ -51,7 +51,7 @@ async function calculateViewAmounts(){

if(logCaching == 'true'){
c.l('View amounts calculated');
console.log(moment(new Date).format('hh:mm:ss A'))
console.log(moment(new Date).format('hh:mm:ss A'));
}

// if(logCaching == 'true'){
Expand Down
10 changes: 5 additions & 5 deletions caching/runCaching.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const dotenv = require('dotenv');
const logCaching = process.env.LOG_CACHING;
const jsHelpers = require('../lib/helpers/js-helpers');

function sleep(ms) {
function sleep(ms){
return new Promise(resolve => setTimeout(resolve, ms));
}

Expand Down Expand Up @@ -116,19 +116,19 @@ console.log(`CACHE TOTAL VIEW INTERVAL IN MINUTES: ${cacheIntervalInMinutes} \n`
async function runRecentInterval(){
// calculate and cache recent uploads every minute
await cacheOnlyRecentUploads();
await sleep(cacheRecentIntervalInMs)
await sleep(cacheRecentIntervalInMs);
runRecentInterval();
}

runRecentInterval();

async function runOtherCaching(){
await cachePopularDailyStatsAndIndex();
await sleep(cacheIntervalInMs)
runOtherCaching()
await sleep(cacheIntervalInMs);
runOtherCaching();
}

runOtherCaching()
runOtherCaching();

// async function main(){
//
Expand Down
11 changes: 5 additions & 6 deletions controllers/backend/internalApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ if(akismetApiKey){
const siteUrl = domainNameAndTLD;
akismetClient = new AkismetClient({ key: akismetApiKey, blog: siteUrl });

(async function() {
(async function(){
const isValid = await akismetClient.verifyKey();

if (isValid){
if(isValid){
console.log('Spam blocking turned on with valid key');
} else {
console.log('Spam blocking turned on but with invalid key');
Expand Down Expand Up @@ -884,9 +884,9 @@ exports.postComment = async(req, res) => {
name: req.user.channelName || req.user.channelUrl
};

const isSpam = await akismetClient.checkSpam(commentCheck)
const isSpam = await akismetClient.checkSpam(commentCheck);

if (isSpam){
if(isSpam){
// create and save comment
let comment = new Comment({
text: req.body.comment,
Expand All @@ -899,7 +899,7 @@ exports.postComment = async(req, res) => {
await comment.save();

res.status(500);
console.log('Spam comment detected')
console.log('Spam comment detected');
return res.send('problem-processing-comment');
}
}
Expand Down Expand Up @@ -985,7 +985,6 @@ exports.postComment = async(req, res) => {
timeAgo
};


res.json(responseObject);

// res.send('success')
Expand Down
7 changes: 3 additions & 4 deletions controllers/backend/uploading.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ exports.postFileUpload = async(req, res) => {

console.log('done moving file');


/** BASIC VIDEO PROCESSING COMPLETED, CHECKING IF NEEDS CONVERSION **/

const specificMatches = ( codecName == 'hevc' || codecProfile == 'High 4:4:4 Predictive' );
Expand Down Expand Up @@ -639,13 +638,13 @@ exports.postFileUpload = async(req, res) => {
if(upload.fileType === 'video'){
// will automatically stick it at /uploads/$channelUrl/$uniqueTag_sprite.png and /$uniqueTag_sprite.vtt
(async function(){
if(user.plan === 'plus') {
await createSpriteImageAndVtt(channelUrl, uniqueTag, fileInDirectory)
if(user.plan === 'plus'){
await createSpriteImageAndVtt(channelUrl, uniqueTag, fileInDirectory);

upload.hasPreviewSpriteThumbnail = true;
await upload.save();
}
})()
})();
}
});

Expand Down
6 changes: 3 additions & 3 deletions controllers/frontend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,17 @@ exports.getComments = async(req, res) => {

const { startingNumber, previousNumber, nextNumber, numbersArray } = pagination.buildPaginationObject(page);

let { visibility } = req.query;
let{ visibility } = req.query;

if(!visibility) visibility = 'all'
if(!visibility) visibility = 'all';

let searchQuery = {};

if(visibility !== 'all'){
searchQuery.visibility = visibility;
}

console.log('visibility')
console.log('visibility');
console.log(visibility);

try {
Expand Down
Loading

0 comments on commit bb03f55

Please sign in to comment.