<commit_before>var Router = require('restify-router').Router;
var router = new Router();
var db = require("../../../../../db");
var WindingProductionOutputManager = require("dl-module").managers.production.spinning.winding.WindingProductionOutput;
var resultFormatter = require("../../../../../result-formatter");

var passport = require('../../../../../passports/jwt-passport');
const apiVersion = '1.0.0';

router.get("/", passport, (request, response, next) => {
    db.get().then(db => {
        var manager = new WindingProductionOutputManager(db, request.user);

        var sorting = {
            "_updatedDate": -1
        };
        var filter = {
            _createdBy: request.user.username
        };

        var query = request.queryInfo;
        query.filter = filter;
        query.order = sorting;
        query.select = [
            "_createdBy", "spinning", "date", "shift", "threadWeight", "goodCone", "badCone", "drum", "product.name","machine.name","lotMachine.lot","product.code"
        ];
        manager.read(query)
            .then(docs => {
                var result = resultFormatter.ok(apiVersion, 200, docs.data);
                delete docs.data;
                delete docs.order;
                result.info = docs;
                response.send(200, result);
            })
            .catch(e => {
                response.send(500, "gagal ambil data");
            });
    })
        .catch(e => {
            var error = resultFormatter.fail(apiVersion, 400, e);
            response.send(400, error);
        });
});

router.get('/:id', passport, (request, response, next) => {
    db.get().then(db => {
        var manager = new WindingProductionOutputManager(db, request.user);

        var id = request.params.id;

        manager.getSingleById(id)
            .then(doc => {
                var result = resultFormatter.ok(apiVersion, 200, doc);<commit_msg>changing spinning into unit winding output<commit_after>var Router = require('restify-router').Router;
var router = new Router();
var db = require("../../../../../db");
var WindingProductionOutputManager = require("dl-module").managers.production.spinning.winding.WindingProductionOutput;
var resultFormatter = require("../../../../../result-formatter");

var passport = require('../../../../../passports/jwt-passport');
const apiVersion = '1.0.0';

router.get("/", passport, (request, response, next) => {
    db.get().then(db => {
        var manager = new WindingProductionOutputManager(db, request.user);

        var sorting = {
            "_updatedDate": -1
        };
        var filter = {
            _createdBy: request.user.username
        };

        var query = request.queryInfo;
        query.filter = filter;
        query.order = sorting;
        query.select = [
            "_createdBy", "unit.name","unit.division", "date", "shift", "threadWeight", "goodCone", "badCone", "drum", "product.name","machine.name","lotMachine.lot","product.code"
        ];
        manager.read(query)
            .then(docs => {
                var result = resultFormatter.ok(apiVersion, 200, docs.data);
                delete docs.data;
                delete docs.order;
                result.info = docs;
                response.send(200, result);
            })
            .catch(e => {
                response.send(500, "gagal ambil data");
            });
    })
        .catch(e => {
            var error = resultFormatter.fail(apiVersion, 400, e);
            response.send(400, error);
        });
});

router.get('/:id', passport, (request, response, next) => {
    db.get().then(db => {
        var manager = new WindingProductionOutputManager(db, request.user);

        var id = request.params.id;

        manager.getSingleById(id)
            .then(doc => {
                var result = resultFormatter.ok(apiVersion, 200, doc);
{'fraction_non_alphanumeric': 0.16355624675997926, 'fraction_numerical': 0.011404872991187144, 'mean_word_length': 2.0481832543443916, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '988730', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1054, 'n_words': 218}