all files / src/controllers/admin/ postCache.js

30% Statements 3/10
0% Branches 0/2
0% Functions 0/1
30% Lines 3/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                             
'use strict';
 
var postCacheController = {};
 
postCacheController.get = function(req, res, next) {
	var cache = require('../../posts/cache');
	var avgPostSize = 0;
	var percentFull = 0;
	if (cache.itemCount > 0) {
		avgPostSize = parseInt((cache.length / cache.itemCount), 10);
		percentFull = ((cache.length / cache.max) * 100).toFixed(2);
	}
 
	res.render('admin/advanced/post-cache', {
		cache: {
			length: cache.length,
			max: cache.max,
			itemCount: cache.itemCount,
			percentFull: percentFull,
			avgPostSize: avgPostSize
		}
	});
};
 
 
module.exports = postCacheController;