<commit_before>'use strict'



/**
 * Example class for Skeleton CRUD
 */
class Skeleton {


    /**
     * constructor - class constructor
     * Creates class properties from the event, context and callback
     * passed in parameters
     *
     * @param  {object} event    description
     * @param  {object} context  description
     * @param  {function} callback description
     * @return {void}
     */

    constructor(event, context, callback) {
        this.event = event;
        this.context = context;
        this.callback = callback;
        // this.responseError = null; // init these
        // this.responseSuccess = null;
    }

    /**
     * getSQSHandler - description
     *
     * @return {type}  description
     */
    getClient() {
        let AWS = require('aws-sdk')
        AWS.config.update({
            region: "eu-west-1",
        });

        return new AWS.DynamoDB.DocumentClient();
    }

    /**
     * creates a record
     *
     * @return {type}  description
     */
    create() {
        let quintus = this;

        let fs = require('fs');

        // get teh data from the event body
        let data = JSON.parse(this.event.body);

        let mydata = {
            "name": data.name,
            "description": data.description,
            "url": data.url,
            "uuid": require('uuid').v4(), // add a unitque identifier
            "updated": new Date().toISOString() // add the updated time to now
        }

        // read in the schema
        let file = fs.readFileSync(process.cwd() + "/schema.json");
        let schema = JSON.parse(file);

        // now lets validate it
        this.validate(mydata, schema)
            .then(function() {
                return quintus.dbWrite(mydata)
            })
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * readOne - description
     *
     * @return {type}  description
     */
    readOne() {
        let quintus = this;

        // get teh data from the event body
        let data = this.event.pathParameters.id

        // now lets validate it
        this.dbRead(data)
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * readAll - scnas table and retrieves all records
     *
     * @return {type}  description
     */
    readAll() {
        let quintus = this;

        this.dbReadAll(data)
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * update - description
     *
     * @return {type}  description
     */
    update() {
        let quintus = this;

        let fs = require('fs');

        // get teh data from the event body
        let data = JSON.parse(this.event.body);

        // read in the schema
        let file = fs.readFileSync(process.cwd() + "/schema.json");
        let schema = JSON.parse(file);

        // add a unitque identifier
        data.uuid = event.pathParameters.id;


        // add the updated time to now
        data.updated = new Date().toISOString();

        // now lets validate it
        this.validate(data, schema)
            .then(function() {
                return quintus.dbupdate(data)
            })
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }<commit_msg>revised update function fix typo in function name<commit_after>'use strict'



/**
 * Example class for Skeleton CRUD
 */
class Skeleton {


    /**
     * constructor - class constructor
     * Creates class properties from the event, context and callback
     * passed in parameters
     *
     * @param  {object} event    description
     * @param  {object} context  description
     * @param  {function} callback description
     * @return {void}
     */

    constructor(event, context, callback) {
        this.event = event;
        this.context = context;
        this.callback = callback;
        // this.responseError = null; // init these
        // this.responseSuccess = null;
    }

    /**
     * getSQSHandler - description
     *
     * @return {type}  description
     */
    getClient() {
        let AWS = require('aws-sdk')
        AWS.config.update({
            region: "eu-west-1",
        });

        return new AWS.DynamoDB.DocumentClient();
    }

    /**
     * creates a record
     *
     * @return {type}  description
     */
    create() {
        let quintus = this;

        let fs = require('fs');

        // get teh data from the event body
        let data = JSON.parse(this.event.body);

        let mydata = {
            "name": data.name,
            "description": data.description,
            "url": data.url,
            "uuid": require('uuid').v4(), // add a unitque identifier
            "updated": new Date().toISOString() // add the updated time to now
        }

        // read in the schema
        let file = fs.readFileSync(process.cwd() + "/schema.json");
        let schema = JSON.parse(file);

        // now lets validate it
        this.validate(mydata, schema)
            .then(function() {
                return quintus.dbWrite(mydata)
            })
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * readOne - description
     *
     * @return {type}  description
     */
    readOne() {
        let quintus = this;

        // get teh data from the event body
        let data = this.event.pathParameters.id

        // now lets validate it
        this.dbRead(data)
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * readAll - scnas table and retrieves all records
     *
     * @return {type}  description
     */
    readAll() {
        let quintus = this;

        this.dbReadAll(data)
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }


    /**
     * update - description
     *
     * @return {type}  description
     */
    update() {
        let quintus = this;

        let fs = require('fs');

        // get teh data from the event body
        let data = JSON.parse(this.event.body);

        // read in the schema
        let file = fs.readFileSync(process.cwd() + "/schema.json");
        let schema = JSON.parse(file);

        // add a unitque identifier
        data.uuid = this.event.pathParameters.id;


        // add the updated time to now
        data.updated = new Date().toISOString();

        // now lets validate it
        this.validate(data, schema)
            .then(function() {
                return quintus.dbUpdate(data)
            })
            .then(function(res) {
                return quintus.successCallback(res)
            })
            .catch((err) => {
                return quintus.errorCallback(err)
            });
    }
{'fraction_non_alphanumeric': 0.11626687639271202, 'fraction_numerical': 0.0005243151133831433, 'mean_word_length': 1.4668606530876172, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 11, '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': '839902', 'n_tokens_mistral': 2150, 'n_tokens_neox': 2040, 'n_words': 515}