'use strict';
const app = require('../business/app.business');
const group = require('../business/group.business');
const scraper = require('../business/scraper.busuness');

module.exports = {
    home: (req, res, next) => {
        group.list().then(x => {
            if (x.length == 1) {
                getRandomImage(req, res, next);
            }
            if (x.length == 0) {
                return res.render('index');
            }
            if (x.length > 1) {
                return res.render('index');
            }
        }).catch(x => console.log(x))
    },

    getRandomImage: (req, res, next) => {
        app.getRandomImage(req.params.group).then((content) => {
            if (content === null) {
                res.redirect('/');
            } else {
                res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
                res.setHeader('Cache-Control', 'post-check=0, pre-check=0');
                res.setHeader('Pragma', 'no-cache');

                res.render('vemardu', { content: content });
            }
        }).catch((err) => {
            res.redirect('/');
        });
    },
    scrape: (req, res, next) => {
        scraper(req.params.group).then((content) => {
            if (content === null) {
                res.sendStatus(400);
            } else {
                res.sendStatus(200);
            }
        }).catch((err) => {
            console.log(err);
            res.sendStatus(500);
        });
    },
}
@@ -230,346 +230,28 @@
     
-group.list().then(x =%3E %7B%0A            if (x.length == 1) %7B%0A                getRandomImage(req, res, next);%0A            %7D%0A            if (x.length == 0) %7B%0A                return res.render('index');%0A            %7D%0A            if (x.length %3E 1) %7B%0A                return res.render('index');%0A            %7D%0A        %7D).catch(x =%3E console.log(x))
+res.render('index');
 %0A   

remove one function