<commit_before>var modCommon = require('module.common');

//TODO make build container at GDropOff's when extractor unlocked
//TODO make build extractor when unlocked
//TODO Storage at flag when unlocked
//TODO Terminal at flag when unlocked
var roleArchitect = {

  //Function to determin if there are buildable structures that need to be
  //assigned a construction site (marked by named flags)
  ableToBuild:function(controllerLvl, structureType){
    var wallBool = (structureType.substring(0,4)==="Wall");
    switch(controllerLvl){
      case 1:
        return (structureType==="Container");
      case 2:
        return (wallBool || structureType === "Extensions1" || structureType==="Container");
      case 3:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType==="Container" || structureType === "Tower1");
      case 4:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType === "Extensions3" || structureType==="Container" || structureType === "Tower1");
      case 5:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType === "Extensions3" || structureType === "Extensions4" || structureType==="Container" || structureType === "Tower1" || structureType === "Tower2" || structureType.substring(0,4)==="Link");
      default:
        return false;
    }
  },

  //Function to mark the pattern of 5 extensions that are granted at
  //controler level 2 and 3
  markExtensions1: function(creep){
    var x = creep.pos.x;
    var y = creep.pos.y;
    creep.room.createConstructionSite(x, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y-1, STRUCTURE_EXTENSION);
  },

  //Function to mark the pattern of 5 extensions that are granted at
  //controler level 4 and 5
  markExtensions2: function(creep){
    var x = creep.pos.x;
    var y = creep.pos.y;
    creep.room.createConstructionSite(x-2, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+2, y-1, STRUCTURE_EXTENSION);

    creep.room.createConstructionSite(x-2, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+2, y+1, STRUCTURE_EXTENSION);
  },

  // marks a container site
  markContainer:function(creep){
      creep.room.createConstructionSite(creep.pos, STRUCTURE_CONTAINER);
  },

  //marks a tower site
  markTower: function(creep){
      creep.room.createConstructionSite(creep.pos, STRUCTURE_TOWER);
  },

  //marks wall sites starting at the flag, going in the specified
  //direction for the given amount of blocks
  markWall:function(creep, flagName){
    var len = parseInt(flagName.substring(5));
    var direction = flagName.substring(4,5);
    var x = creep.pos.x;
    var y = creep.pos.y;
    if(direction === "U"){
        for(i=0; i<=len; i++){
          creep.room.createConstructionSite(x, y-i, STRUCTURE_WALL);
        }
    }else if(direction === "D"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x,y+i, STRUCTURE_WALL);
      }
    }else if(direction === "R"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x+i,y, STRUCTURE_WALL);
      }
    }else if(direction === "L"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x-i,+y, STRUCTURE_WALL);
      }
    }
  },

  /** @param {Creep} creep **/
  run: function(creep) {
    var controllerLvl = creep.room.controller.level;
    var flags = _.filter(creep.room.find(FIND_FLAGS), (flag) => this.ableToBuild(controllerLvl, flag.name));
    if(creep.memory.working && flags.length<1) {
        creep.memory.working = false;
        creep.memory.path = null;
    }
    if(!creep.memory.working && flags.length) {
        creep.memory.working = true;
        creep.memory.path = null;
    }

    if(!creep.memory.working){
      Memory.roles.numArchitects = Memory.roles.numArchitects - 1;
      Memory.roles.numBuilders = Memory.roles.numBuilders + 1;
      creep.memory.role = 'builder';
      if(controllerLvl<=1){
        creep.memory.selfHarvest = true;
      }
    }else{
      var flag = flags[0];
      if(!creep.pos.isEqualTo(flag.pos)){
        modCommon.move(creep,flag.pos);
      }else{
        if(flag.name === "Container"){
          this.markContainer(creep);
          flag.remove();
          creep.memory.path = null;
        }else if(flag.name === "Tower1" || flag.name === "Tower2"){
            this.markTower(creep);
            flag.remove();
            creep.memory.path =null;
        }else if(flag.name === "Extensions1" || flag.name ==="Extensions2"){
            this.markExtensions1(creep);
            flag.remove();
            creep.memory.path =null;
        }else if(flag.name === "Extensions3" || flag.name ==="Extensions4"){
            this.markExtensions2(creep);
            flag.remove();
            creep.memory.path = null;
        }else if(flag.name.substring(0,4)==="Wall"){
            this.markWall(creep, flag.name);
            flag.remove();
            creep.memory.path =null;
        }
      }
    }
  }
};

module.exports = roleArchitect;
<commit_msg>TODOs and method header<commit_after>var modCommon = require('module.common');

//TODO make build container at GDropOff's when extractor unlocked
//TODO make build extractor when unlocked
//TODO Storage at flag when unlocked
//TODO Terminal at flag when unlocked
var roleArchitect = {

  //Function to determin if there are buildable structures that need to be
  //assigned a construction site (marked by named flags)
  //TODO finish this method for through controllerLvl 8
  ableToBuild:function(controllerLvl, structureType){
    var wallBool = (structureType.substring(0,4)==="Wall");
    switch(controllerLvl){
      case 1:
        return (structureType==="Container");
      case 2:
        return (wallBool || structureType === "Extensions1" || structureType==="Container");
      case 3:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType==="Container" || structureType === "Tower1");
      case 4:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType === "Extensions3" || structureType==="Container" || structureType === "Tower1");
      case 5:
        return (wallBool || structureType === "Extensions1" || structureType === "Extensions2" || structureType === "Extensions3" || structureType === "Extensions4" || structureType==="Container" || structureType === "Tower1" || structureType === "Tower2" || structureType.substring(0,4)==="Link");
      default:
        return false;
    }
  },

  //Function to mark the pattern of 5 extensions that are granted at
  //controler level 2 and 3
  markExtensions1: function(creep){
    var x = creep.pos.x;
    var y = creep.pos.y;
    creep.room.createConstructionSite(x, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y-1, STRUCTURE_EXTENSION);
  },

  //Function to mark the pattern of 5 extensions that are granted at
  //controler level 4 and 5
  markExtensions2: function(creep){
    var x = creep.pos.x;
    var y = creep.pos.y;
    creep.room.createConstructionSite(x-2, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y-1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+2, y-1, STRUCTURE_EXTENSION);

    creep.room.createConstructionSite(x-2, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x-1, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+1, y+1, STRUCTURE_EXTENSION);
    creep.room.createConstructionSite(x+2, y+1, STRUCTURE_EXTENSION);
  },

  // marks a container site
  markContainer:function(creep){
      creep.room.createConstructionSite(creep.pos, STRUCTURE_CONTAINER);
  },

  //marks a tower site
  markTower: function(creep){
      creep.room.createConstructionSite(creep.pos, STRUCTURE_TOWER);
  },

  //marks wall sites starting at the flag, going in the specified
  //direction for the given amount of blocks
  markWall:function(creep, flagName){
    var len = parseInt(flagName.substring(5));
    var direction = flagName.substring(4,5);
    var x = creep.pos.x;
    var y = creep.pos.y;
    if(direction === "U"){
        for(i=0; i<=len; i++){
          creep.room.createConstructionSite(x, y-i, STRUCTURE_WALL);
        }
    }else if(direction === "D"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x,y+i, STRUCTURE_WALL);
      }
    }else if(direction === "R"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x+i,y, STRUCTURE_WALL);
      }
    }else if(direction === "L"){
      for(i=0; i<=len; i++){
        creep.room.createConstructionSite(x-i,+y, STRUCTURE_WALL);
      }
    }
  },

  //Marks the minerals in the room for an extractor construction site
  //TODO implement this method and use it
  markExtractor:function(creep){},

  /** @param {Creep} creep **/
  run: function(creep) {
    var controllerLvl = creep.room.controller.level;
    var flags = _.filter(creep.room.find(FIND_FLAGS), (flag) => this.ableToBuild(controllerLvl, flag.name));
    if(creep.memory.working && flags.length<1) {
        creep.memory.working = false;
        creep.memory.path = null;
    }
    if(!creep.memory.working && flags.length) {
        creep.memory.working = true;
        creep.memory.path = null;
    }

    if(!creep.memory.working){
      Memory.roles.numArchitects = Memory.roles.numArchitects - 1;
      Memory.roles.numBuilders = Memory.roles.numBuilders + 1;
      creep.memory.role = 'builder';
      if(controllerLvl<=1){
        creep.memory.selfHarvest = true;
      }
    }else{
      var flag = flags[0];
      if(!creep.pos.isEqualTo(flag.pos)){
        modCommon.move(creep,flag.pos);
      }else{
        if(flag.name === "Container"){
          this.markContainer(creep);
          flag.remove();
          creep.memory.path = null;
        }else if(flag.name === "Tower1" || flag.name === "Tower2"){
            this.markTower(creep);
            flag.remove();
            creep.memory.path =null;
        }else if(flag.name === "Extensions1" || flag.name ==="Extensions2"){
            this.markExtensions1(creep);
            flag.remove();
            creep.memory.path =null;
        }else if(flag.name === "Extensions3" || flag.name ==="Extensions4"){
            this.markExtensions2(creep);
            flag.remove();
            creep.memory.path = null;
        }else if(flag.name.substring(0,4)==="Wall"){
            this.markWall(creep, flag.name);
            flag.remove();
            creep.memory.path =null;
        }
      }
    }
  }
};

module.exports = roleArchitect;
<|endoftext|>


<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App />, div);
});
<commit_msg>removed react test<commit_after><|endoftext|>


<commit_before>import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import { shallow, mount } from 'enzyme';
import renderer from 'react-test-renderer';

import App from './App';
import { ImageView, DateNavigator, Title } from './components';
import { PreCacheImg } from './shared';

// Mock 3rd-party-library (used as HOC)
// using doMock instead of mock to avoid warnings of unknown props
// due to: https://stackoverflow.com/questions/44403165/using-jest-to-mock-a-react-component-with-props
// jest.doMock('react-hotkeys', () => {
//     return jest.fn(() => <div />);
// });
jest.mock('react-hotkeys', () => {
    return {
        HotKeys: 'hotkeys'
    };
});

describe('App', () => {
    let props;
    let mountedApp;
    let shallowApp;
    const app = () => {
        if (!mountedApp) {
            mountedApp = mount(
                <App {...props} />
            );
        }
        return mountedApp;
    };
    const appShallow = () => {
        if (!shallowApp) {
            shallowApp = shallow(
                <App {...props} />
            );
        }
        return shallowApp;
    };

    beforeEach(() => {
        // App = require('./App').default;
        props = {
            date: new Date(2017, 5, 12)
        };
        mountedApp = undefined;
        shallowApp = undefined;
    });

    it('calls componentDidMount (just for example)', () => {
        App.prototype.componentDidMount = jest.fn();
        app();
        // const instance = wrapper.instance();
        expect(App.prototype.componentDidMount).toHaveBeenCalled();
    });

    it('renders shallow', () => {
        appShallow();
        // expect(wrapper.contains(welcome)).toEqual(true);
        // simpler version for this:
        // expect(wrapper).toContainReact(welcome);
    });

    it('renders without crashing', () => {
        ReactTestUtils.renderIntoDocument(<App {...props} />);
    });

    it('mounts successfully (full DOM rendering)', () => {
        app();
    });

    it('always renders 4 top-level divs', () => {
        const divs = appShallow().find('div'); // shallow goes only 1 level deep
        expect(divs.length).toBe(4);
    });

    it('always renders `.App-Title` div', () => {
        const div = app().find('div .App-Title');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Title` div', () => {
        const div = () => app().find('div .App-Title');

        it('contains everything else that gets rendered', () => {
            // const div = app().find('div .App-Title'); // This hangs!
            const div = appShallow().find('div .App-Title');

            // When using .find, enzyme arranges the nodes in order such
            // that the outermost node is first in the list. So we can
            // use .first() to get the outermost div.
            const wrappingDiv = div.find('div .App-Title').first();
            // console.log(divs.first().debug());
            // console.log(appShallow().childAt(1).debug());
            // Enzyme omits the outermost node when using the .children()
            // method on app(). This is annoying, but we can use it
            // to verify that wrappingDiv contains everything else this
            // component renders.
            expect(wrappingDiv).toEqual(appShallow().childAt(0));
        });
        it('always renders a `Title`', () => {
            expect(div().find(Title).length).toBe(1);
        });
        it('`Title` receives `title` prop', () => {
            const title = (div().find(Title));
            expect(Object.keys(title.props()).length).toBe(1);
            expect(title.props().value).toBe('Our daily bread');
        });
    });

    it('always renders `.App-Main div`', () => {
        const div = app().find('div .App-Main');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Main` div', () => {
        const div = () => app().find('div .App-Main');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Main');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(1));
        });
        it('always renders a `ImageView`', () => {
            expect(div().find(ImageView).length).toBe(1);
        });
        it('`ImageView` receives 1 prop', () => {
            const imageView = (div().find(ImageView));
            expect(Object.keys(imageView.props()).length).toBe(1);
        });
        it('`ImageView` receives `url` prop', () => {
            // We take the exact url here instead of duplicating the
            // logic from App.jsx (that would make the test more brittle)
            const url = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-12.png';
            const imageView = (div().find(ImageView));
            expect(imageView.props().url).toBe(url);
        });
        it('`ImageView` receives `onChangeDate` prop', () => {
            const dateNav = (div().find(ImageView));
            expect(dateNav.props().onChangeDate).toBeDefined;
            // expect(dateNav.props().onChangeDate).toBe(App.propTypes.updateDate);
        });
        it('always renders a `ImageView`', () => {
            expect(div().find(ImageView).length).toBe(1);
        });

        it('`PreCacheImg` receives 1 prop', () => {
            const precacheImg = (div().find(PreCacheImg));
            expect(Object.keys(precacheImg.props()).length).toBe(1);
        });
        it('`PreCacheImg` receives `images` prop', () => {
            // We take the exact url here instead of duplicating the
            // logic from App.jsx (that would make the test more brittle)
            const url = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-12.png';
            const url1 = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-11.png';
            const url2 = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-13.png'
            const images = [ url, url1, url2];
            const precacheImg = (div().find(PreCacheImg));
            // use toEqual for arrays (not `toBe` which uses ===)
            expect(precacheImg.props().images).toEqual([images]);
        });
    });

    it('always renders `.App-Handle` div', () => {
        const div = app().find('div .App-Handle');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Handle` div', () => {
        const div = () => app().find('div .App-Handle');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Handle');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(2));
        });
        it('always renders a `DateNavigator`', () => {
            expect(div().find(DateNavigator).length).toBe(1);
        });
        it('`DateNavigator` receives 2 props', () => {
            const dateNav = (div().find(DateNavigator));
            expect(Object.keys(dateNav.props()).length).toBe(2);
        });
        it('`DateNavigator` receives `date` prop', () => {
            const dateNav = (div().find(DateNavigator));
            expect(dateNav.props().date).toBe(props.date);
        });
        it('`DateNavigator` receives `onChangeDate` prop', () => {
            const dateNav = (div().find(DateNavigator));
            expect(dateNav.props().onChangeDate).toBeDefined;
            // expect(dateNav.props().onChangeDate).toBe(App.propTypes.updateDate);
        });
    });

    it('always renders `.App-Footer` div', () => {
        const divs = app().find('div .App-Footer');
        expect(divs.length).toBe(1);
    });
    describe('the rendered `.App-Footer` div', () => {
        const div = () => app().find('div .App-Footer');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Footer');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(3));
        });
    });

    it('did not change UI compared to recorded snapshot', () => {
        // jest.doMock('react-hotkeys', () => {
        //     const HotKeys = () => <div />;
        //     return HotKeys;
        // });
        // const App = require('./App').default;
        const component = renderer.create(<App {...props} />);
        // component.state = { date: new Date(2017, 7, 1) };
        const tree = component.toJSON();
        expect(tree).toMatchSnapshot();
    });
});
<commit_msg>completed PreCacheImg testcase<commit_after>import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import { shallow, mount } from 'enzyme';
import renderer from 'react-test-renderer';

import App from './App';
import { ImageView, DateNavigator, Title } from './components';
import { PreCacheImg } from './shared';

// Mock 3rd-party-library (used as HOC)
// using doMock instead of mock to avoid warnings of unknown props
// due to: https://stackoverflow.com/questions/44403165/using-jest-to-mock-a-react-component-with-props
// jest.doMock('react-hotkeys', () => {
//     return jest.fn(() => <div />);
// });
jest.mock('react-hotkeys', () => {
    return {
        HotKeys: 'hotkeys'
    };
});

describe('App', () => {
    let props;
    let mountedApp;
    let shallowApp;
    const app = () => {
        if (!mountedApp) {
            mountedApp = mount(
                <App {...props} />
            );
        }
        return mountedApp;
    };
    const appShallow = () => {
        if (!shallowApp) {
            shallowApp = shallow(
                <App {...props} />
            );
        }
        return shallowApp;
    };

    beforeEach(() => {
        // App = require('./App').default;
        props = {
            date: new Date(2017, 5, 12)
        };
        mountedApp = undefined;
        shallowApp = undefined;
    });

    it('calls componentDidMount (just for example)', () => {
        App.prototype.componentDidMount = jest.fn();
        app();
        // const instance = wrapper.instance();
        expect(App.prototype.componentDidMount).toHaveBeenCalled();
    });

    it('renders shallow', () => {
        appShallow();
        // expect(wrapper.contains(welcome)).toEqual(true);
        // simpler version for this:
        // expect(wrapper).toContainReact(welcome);
    });

    it('renders without crashing', () => {
        ReactTestUtils.renderIntoDocument(<App {...props} />);
    });

    it('mounts successfully (full DOM rendering)', () => {
        app();
    });

    it('always renders 4 top-level divs', () => {
        const divs = appShallow().find('div'); // shallow goes only 1 level deep
        expect(divs.length).toBe(4);
    });

    it('always renders `.App-Title` div', () => {
        const div = app().find('div .App-Title');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Title` div', () => {
        const div = () => app().find('div .App-Title');

        it('contains everything else that gets rendered', () => {
            // const div = app().find('div .App-Title'); // This hangs!
            const div = appShallow().find('div .App-Title');

            // When using .find, enzyme arranges the nodes in order such
            // that the outermost node is first in the list. So we can
            // use .first() to get the outermost div.
            const wrappingDiv = div.find('div .App-Title').first();
            // console.log(divs.first().debug());
            // console.log(appShallow().childAt(1).debug());
            // Enzyme omits the outermost node when using the .children()
            // method on app(). This is annoying, but we can use it
            // to verify that wrappingDiv contains everything else this
            // component renders.
            expect(wrappingDiv).toEqual(appShallow().childAt(0));
        });
        it('always renders a `Title`', () => {
            expect(div().find(Title).length).toBe(1);
        });
        it('`Title` receives `title` prop', () => {
            const title = (div().find(Title));
            expect(Object.keys(title.props()).length).toBe(1);
            expect(title.props().value).toBe('Our daily bread');
        });
    });

    it('always renders `.App-Main div`', () => {
        const div = app().find('div .App-Main');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Main` div', () => {
        const div = () => app().find('div .App-Main');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Main');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(1));
        });
        it('always renders a `ImageView`', () => {
            expect(div().find(ImageView).length).toBe(1);
        });
        it('`ImageView` receives 1 prop', () => {
            const imageView = (div().find(ImageView));
            expect(Object.keys(imageView.props()).length).toBe(1);
        });
        it('`ImageView` receives `url` prop', () => {
            // We take the exact url here instead of duplicating the
            // logic from App.jsx (that would make the test more brittle)
            const url = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-12.png';
            const imageView = (div().find(ImageView));
            expect(imageView.props().url).toBe(url);
        });
        it('`ImageView` receives `onChangeDate` prop', () => {
            const dateNav = (div().find(ImageView));
            expect(dateNav.props().onChangeDate).toBeDefined;
            // expect(dateNav.props().onChangeDate).toBe(App.propTypes.updateDate);
        });
        it('always renders a `ImageView`', () => {
            expect(div().find(ImageView).length).toBe(1);
        });

        it('`PreCacheImg` receives 1 prop', () => {
            const precacheImg = (div().find(PreCacheImg));
            expect(Object.keys(precacheImg.props()).length).toBe(1);
        });
        it('`PreCacheImg` receives `images` prop', () => {
            // We take the exact url here instead of duplicating the
            // logic from App.jsx (that would make the test more brittle)
            const url = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-12.png';
            const url1 = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-11.png';
            const url2 = 'https://logos.com/media/VerseOfTheDay/768x432/2017-06-13.png'
            const images = [url, url1, url2];
            const precacheImg = (div().find(PreCacheImg));
            // use toEqual for arrays (not `toBe` which uses ===)
            expect(precacheImg.props().images).toEqual([images]);
        });
    });

    it('always renders `.App-Handle` div', () => {
        const div = app().find('div .App-Handle');
        expect(div.length).toBe(1);
    });
    describe('the rendered `.App-Handle` div', () => {
        const div = () => app().find('div .App-Handle');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Handle');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(2));
        });
        it('always renders a `DateNavigator`', () => {
            expect(div().find(DateNavigator).length).toBe(1);
        });
        it('`DateNavigator` receives 2 props', () => {
            const dateNav = (div().find(DateNavigator));
            expect(Object.keys(dateNav.props()).length).toBe(2);
        });
        it('`DateNavigator` receives `date` prop', () => {
            const dateNav = (div().find(DateNavigator));
            expect(dateNav.props().date).toBe(props.date);
        });
        it('`DateNavigator` receives `onChangeDate` prop', () => {
            const dateNav = (div().find(DateNavigator));
            expect(dateNav.props().onChangeDate).toBeDefined;
            // expect(dateNav.props().onChangeDate).toBe(App.propTypes.updateDate);
        });
    });

    it('always renders `.App-Footer` div', () => {
        const divs = app().find('div .App-Footer');
        expect(divs.length).toBe(1);
    });
    describe('the rendered `.App-Footer` div', () => {
        const div = () => app().find('div .App-Footer');

        it('contains everything else that gets rendered', () => {
            const div = appShallow().find('div .App-Footer');
            const wrappingDiv = div.first();
            expect(wrappingDiv).toEqual(appShallow().childAt(3));
        });
    });

    it('did not change UI compared to recorded snapshot', () => {
        // jest.doMock('react-hotkeys', () => {
        //     const HotKeys = () => <div />;
        //     return HotKeys;
        // });
        // const App = require('./App').default;
        const component = renderer.create(<App {...props} />);
        // component.state = { date: new Date(2017, 7, 1) };
        const tree = component.toJSON();
        expect(tree).toMatchSnapshot();
    });
});
<|endoftext|>


<commit_before>(function(){"use strict";function r(r){var u,o,i=t(r.units),f=n(r.from,i),s=n(r.until,i,Date.now());return u=s-f,u>0?o="past":(o="future",u=-u),e(u,o)}function t(r){if(r===void 0)return"s";if("s"===r||"ms"===r)return r;throw Error("Invalid units")}function n(r,t,n){if(r===void 0&&"number"==typeof n)return n;if("string"==typeof r&&(r=parseInt(r,10)),"number"!=typeof r||isNaN(r))throw Error("Invalid timestamp");return"s"===t?1e3*r:r}function e(r,t){var n,e;for(n in f)if(f.hasOwnProperty(n)&&r>=f[n])return e=Math.floor(r/f[n]),a[t](e,u(n,e));return s[t]}function u(r,t){return r+(t>1?"s":"")}function o(r,t){return r+" "+t+" ago"}function i(r,t){return"in "+r+" "+t}var f={year:315576e5,month:26298e5,week:6048e5,day:864e5,hour:36e5,minute:6e4},s={past:"just now",future:"now"},a={past:o,future:i};exports?exports.get=r:window.vagueTime={get:r}})();<commit_msg>Update mininfied script.<commit_after>(function(){"use strict";function t(t){var u,o,i=r(t.units),f=Date.now(),s=n(t.from,i,f),a=n(t.to,i,f);return u=s-a,u>0?o="past":(o="future",u=-u),e(u,o)}function r(t){if(t===void 0)return"s";if("s"===t||"ms"===t)return t;throw Error("Invalid units")}function n(t,r,n){if(t===void 0)return n;if("string"==typeof t&&(t=parseInt(t,10)),"number"!=typeof t||isNaN(t))throw Error("Invalid timestamp");return"s"===r?1e3*t:t}function e(t,r){var n,e;for(n in f)if(f.hasOwnProperty(n)&&t>=f[n])return e=Math.floor(t/f[n]),a[r](e,u(n,e));return s[r]}function u(t,r){return t+(r>1?"s":"")}function o(t,r){return t+" "+r+" ago"}function i(t,r){return"in "+t+" "+r}var f={year:315576e5,month:26298e5,week:6048e5,day:864e5,hour:36e5,minute:6e4},s={past:"just now",future:"now"},a={past:o,future:i};"undefined"!=typeof exports?exports.get=t:window.vagueTime={get:t}})();<|endoftext|>


<commit_before>'use strict';

const express = require('express');
const router = express.Router();

router.get('/default', (req, res) => {
  res.send("I'm workin here");
});

module.exports = router;<commit_msg>initial commit<commit_after>'use strict';

const express = require('express');
const router = express.Router();

router.get('/default', (req, res) => {
  res.send('I\'m workin here');
});

module.exports = router;<|endoftext|>


<commit_before>/* Event Emitter */
var util = require('util');
var EventEmitter = require('events').EventEmitter;

/* ZeroMQ */
var zmq = require('zmq')
  , sock = zmq.socket('sub')
  , sock2 = zmq.socket('pub');

//sock2.bindSync('tcp://127.0.0.1:5001');

/* Request */
var request = require('request');

// Mapping from Human Readable names to lagarto assigned ID's
// Not to be confussed with the experimental node ID, which will be unique to the arrangement of each session

// Feeder Devices
var lagartoIDtofeederName = {'7': 'a', '6': 'b', '0': 'c', '0': 'd', '0': 'e',
							'0': 'f', '0': 'g', '0': 'h', '0': 'i', '0': 'j'};

var feederNameToLagartoID = {'a': '7', 'b': '6', 'c': '0', 'd': '0', 'e': '0',
							'f': '0', 'g': '0', 'h': '0', 'i': '0', 'j': '0'};

var lagartoDotReferenceToFeederFunction = {'11.0': 'dropMeat', '17.0': 'perchEvent', '0': 'event'}; // battery, reset etc etc etc

var feederFunctionToLagartoDotReference = {'dropMeat': '11.0', 'perchEvent': '17.0', 'event': '0'}; // battery, reset etc etc etc

// Indicator device
var indicatorToLagartoID = {'indicator1': '0'};
var indicatorFunctionToLagartoDotReference = {'1': '0', '2': '0', '3': '0', '4': '0', '5': '0', '6': '0',
											  '7': '0', '8': '0', '9': '0', '10': '0',};

// The EventEmitter Object that will report events back to the controller
// Like a Meerkat, it is good at keeping watch : )
var Meerkat = function() {

    // we need to store the reference of `this` to `self`, so that we can use the current context in the setTimeout (or any callback) functions
    // using `this` in the setTimeout functions will refer to those funtions, not the Radio class
    var self = this;

    // Connect to Lagarto over ZMQ to subscrbe to events
	sock.connect('tcp://0.0.0.0:5001');
	sock.subscribe('');
	console.log('Subscriber connected to port 5001');

	sock.on('message', function(topic, message) {
	  	console.log('Recieved Message: "%s"', topic);

	  	parsedMessage = String(topic);
	  	jsonMessage = JSON.parse(parsedMessage);
	  	protcolName = jsonMessage['lagarto']['procname'];
	  	httpServer = jsonMessage['lagarto']['httpserver'];
	  	status = jsonMessage['lagarto']['status'];

	  	if (typeof status === "undefined") {
		    console.log("status not defined");
		} else {
			console.log(status);

	  		// Becuase it may contain multple values to status
	  		for (var i=0; i<status.length; i++) {
	  			name = status[i]['name'];
	  			idAndFunction = status[i]['id'];
	  			id = idAndFunction; //pull out the start
	  			functionID = idAndFunction; //pull out the end
	  			value = status[i]['value'];

	  			console.log("Event details are:", name, idAndFunction, value);

	  			// Hardcoded values - to be removed
			  	eventType = 'perchEvent2';
			  	deviceID = 1; // get this from
			  	perchID = 1;
			  	value = 'on';

	  			// Did it come from the indicator?
	  			if (id == indicatorToLagartoID['indicator1']) {

	  				eventType = indicatorFunctionToLagartoDotReference[functionID];

	  				switch (eventType) {
	  					case '':

	  						break;
	  					case '':

	  						break;
	  					case '':

	  						break;
	  					default:

	  				}
	  			}

	  			// Did it come from a feeder node
	  			if (feederNameToLagartoID[id]) { // is this device ID mapped to a feeder

	  				eventType = feederFunctionToLagartoDotReference[functionID];

	  				switch (eventType) {
				    	case 'perchEvent':
				        	console.log("PerchEvent", deviceID, value);

				        	// Pasrse message, and topic

				        	perchID = 1; //set this based on the contents of the message
				        	self.emit('perchEvent', perchID);

				        	break;
				    	case 'MeatFinishedDropping':
					        console.log("MeatFinishedDropping", deviceID, value);

					        // Pasrse message, and topic

					        feederID = 1; //set this based on the contents of the message
					        self.emit('MeatDropped', feederID)

				        	break;
				    	case 'LightChanged':
					        console.log("LightChanged", lightID);

					        // Pasrse message, and topic

					        lightID = 1; //set this based on the contents of the message
					        self.emit('LightChanged', lightID)

					        break;
				    	case 'BatteryUpdate':
					        console.log("BatteryUpdated", deviceID);

					        // Pasrse message, and topic

					        lightID = 1; //set this based on the contents of the message
					        self.emit('BatteryUpdated', deviceID)

					        break;
				    	default:
					        console.log("unhandled event");

					        perchID = 1; //set this based on the contents of the message
					        self.emit('dunno', perchID);
					}
	  			}

	  		}
	  	}

	  });
		// Reset
		// "{"lagarto":
				//{
				//"status":
					//[{"direction": "out", "name": "Reset_7", "timestamp": "28 May 2015 06:00:17", "value": "on", "location": "SWAP", "type": "bin", "id": "7.12.0"}],
				//"procname": "Lagarto-SWAP",
				//"httpserver": "10.1.1.6:8001"
				//}
			//}"

		// Perch off
		//"{"lagarto":
			//{"status":
				//[{"direction": "inp", "name": "Perch_triggered_7", "timestamp": "28 May 2015 05:59:34", "value": "off", "location": "SWAP", "type": "bin", "id": "7.17.0"}],
			//"procname": "Lagarto-SWAP", "httpserver": "10.1.1.6:8001"}}"

		// Perch event to parse
		//"{"lagarto":
			//{"status":
				//[{"direction": "inp", "name": "Perch_triggered_7", "timestamp": "28 May 2015 05:59:34", "value": "on", "location": "SWAP", "type": "bin", "id": "7.17.0"}],
			//"procname": "Lagarto-SWAP", "httpserver": "10.1.1.6:8001"}}"

    // EventEmitters inherit a single event listener, see it in action
    this.on('newListener', function(listener) {
        console.log('Event Listener: ' + listener);
    });

};

// extend the EventEmitter class using our Meerkat class
util.inherits(Meerkat, EventEmitter);

// Methods to be exported
var exports = module.exports = {};

// we specify that this module is a refrence to the Meerkat class
exports.Meerkat = Meerkat;

// Test method to be removed...
exports.sendMessage = function() {
  console.log('sending a multipart message envelope');
  sock2.send(["{'lagarto': 'hello'}", 'meow!']);
};

//
// Detecting Devices Methods
//
exports.getDevices = function() {

	//Perhaps this should pre cache??

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=7.11.0&value=true', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent")
      }
    })
};

exports.getBatteryLife = function() {

	// return all the remaining battery lifes
	// do some in an arrary like
	return currentBattery = [1,1,1,1,1,1,1,1,1,1];
}

//
// Meat Events
//
exports.dropMeat = function(deviceName) {

	// map device name, and the function to below
	deviceID = feederNameToLagartoID[deviceName];
	functionID = feederFunctionToLagartoDotReference['dropMeat']; //maps to 11.0
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'true';

	console.log("Dropping Meat on: ", deviceName);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent drop meat command")
      }
    })
};

exports.getRemainingMeat = function(deviceName) {

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=7.11.0&value=true', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent")
      }
    })

};

//
// Light Events
//
exports.turnLightOn = function(experimentalLightID) {

	deviceID = indicatorToLagartoID['indicator1'];
	functionID = indicatorFunctionToLagartoDotReference[experimentalLightID];
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'true'; //or perhaps off / on ??

	console.log("Turning Light on: ", experimentalLightID);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent turn ligh on command")
      }
    })

};

exports.turnLightOff = function(experimentalLightID) {

	deviceID = indicatorToLagartoID['indicator1'];
	functionID = indicatorFunctionToLagartoDotReference[experimentalLightID];
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'false'; //or perhaps off / on ??

	console.log("Turning Light off on: ", experimentalLightID);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent turn light off command")
      }
    })

};<commit_msg>testing json parsing<commit_after>/* Event Emitter */
var util = require('util');
var EventEmitter = require('events').EventEmitter;

/* ZeroMQ */
var zmq = require('zmq')
  , sock = zmq.socket('sub')
  , sock2 = zmq.socket('pub');

//sock2.bindSync('tcp://127.0.0.1:5001');

/* Request */
var request = require('request');

// Mapping from Human Readable names to lagarto assigned ID's
// Not to be confussed with the experimental node ID, which will be unique to the arrangement of each session

// Feeder Devices
var lagartoIDtofeederName = {'7': 'a', '6': 'b', '0': 'c', '0': 'd', '0': 'e',
							'0': 'f', '0': 'g', '0': 'h', '0': 'i', '0': 'j'};

var feederNameToLagartoID = {'a': '7', 'b': '6', 'c': '0', 'd': '0', 'e': '0',
							'f': '0', 'g': '0', 'h': '0', 'i': '0', 'j': '0'};

var lagartoDotReferenceToFeederFunction = {'11.0': 'dropMeat', '17.0': 'perchEvent', '0': 'event'}; // battery, reset etc etc etc

var feederFunctionToLagartoDotReference = {'dropMeat': '11.0', 'perchEvent': '17.0', 'event': '0'}; // battery, reset etc etc etc

// Indicator device
var indicatorToLagartoID = {'indicator1': '0'};
var indicatorFunctionToLagartoDotReference = {'1': '0', '2': '0', '3': '0', '4': '0', '5': '0', '6': '0',
											  '7': '0', '8': '0', '9': '0', '10': '0',};

// The EventEmitter Object that will report events back to the controller
// Like a Meerkat, it is good at keeping watch : )
var Meerkat = function() {

    // we need to store the reference of `this` to `self`, so that we can use the current context in the setTimeout (or any callback) functions
    // using `this` in the setTimeout functions will refer to those funtions, not the Radio class
    var self = this;

    // Connect to Lagarto over ZMQ to subscrbe to events
	sock.connect('tcp://0.0.0.0:5001');
	sock.subscribe('');
	console.log('Subscriber connected to port 5001');

	sock.on('message', function(topic, message) {
	  	console.log('Recieved Message: "%s"', topic);

	  	parsedMessage = String(topic);
	  	jsonMessage = JSON.parse(parsedMessage);
	  	protcolName = jsonMessage['lagarto']['procname'];
	  	httpServer = jsonMessage['lagarto']['httpserver'];
	  	status = jsonMessage['lagarto']['status'];

	  	if (typeof status === "undefined") {
		    console.log("status not defined");
		} else {
			console.log(status);

	  		// Becuase it may contain multple values to status
	  		for (var i=0; i<status.length; i++) {
	  			name = status[i]['name'];
	  			idAndFunction = status[i]['id'].split(".");
	  			id = idAndFunction[0]; //pull out the start
	  			functionID = idAndFunction[1]+"."+idAndFunction[1]; //pull out the end
	  			value = status[i]['value'];

	  			console.log("Event details are:", name, idAndFunction, value);

	  			// Hardcoded values - to be removed
			  	eventType = 'perchEvent2';
			  	deviceID = 1; // get this from
			  	perchID = 1;
			  	value = 'on';

	  			// Did it come from the indicator?
	  			if (id == indicatorToLagartoID['indicator1']) {

	  				eventType = indicatorFunctionToLagartoDotReference[functionID];

	  				switch (eventType) {
	  					case '':

	  						break;
	  					case '':

	  						break;
	  					case '':

	  						break;
	  					default:

	  				}
	  			}

	  			// Did it come from a feeder node
	  			if (feederNameToLagartoID[id]) { // is this device ID mapped to a feeder

	  				eventType = feederFunctionToLagartoDotReference[functionID];

	  				switch (eventType) {
				    	case 'perchEvent':
				        	console.log("PerchEvent", deviceID, value);

				        	// Pasrse message, and topic

				        	perchID = 1; //set this based on the contents of the message
				        	self.emit('perchEvent', perchID);

				        	break;
				    	case 'MeatFinishedDropping':
					        console.log("MeatFinishedDropping", deviceID, value);

					        // Pasrse message, and topic

					        feederID = 1; //set this based on the contents of the message
					        self.emit('MeatDropped', feederID)

				        	break;
				    	case 'LightChanged':
					        console.log("LightChanged", lightID);

					        // Pasrse message, and topic

					        lightID = 1; //set this based on the contents of the message
					        self.emit('LightChanged', lightID)

					        break;
				    	case 'BatteryUpdate':
					        console.log("BatteryUpdated", deviceID);

					        // Pasrse message, and topic

					        lightID = 1; //set this based on the contents of the message
					        self.emit('BatteryUpdated', deviceID)

					        break;
				    	default:
					        console.log("unhandled event");

					        perchID = 1; //set this based on the contents of the message
					        self.emit('dunno', perchID);
					}
	  			}

	  		}
	  	}

	  });
		// Reset
		// "{"lagarto":
				//{
				//"status":
					//[{"direction": "out", "name": "Reset_7", "timestamp": "28 May 2015 06:00:17", "value": "on", "location": "SWAP", "type": "bin", "id": "7.12.0"}],
				//"procname": "Lagarto-SWAP",
				//"httpserver": "10.1.1.6:8001"
				//}
			//}"

		// Perch off
		//"{"lagarto":
			//{"status":
				//[{"direction": "inp", "name": "Perch_triggered_7", "timestamp": "28 May 2015 05:59:34", "value": "off", "location": "SWAP", "type": "bin", "id": "7.17.0"}],
			//"procname": "Lagarto-SWAP", "httpserver": "10.1.1.6:8001"}}"

		// Perch event to parse
		//"{"lagarto":
			//{"status":
				//[{"direction": "inp", "name": "Perch_triggered_7", "timestamp": "28 May 2015 05:59:34", "value": "on", "location": "SWAP", "type": "bin", "id": "7.17.0"}],
			//"procname": "Lagarto-SWAP", "httpserver": "10.1.1.6:8001"}}"

    // EventEmitters inherit a single event listener, see it in action
    this.on('newListener', function(listener) {
        console.log('Event Listener: ' + listener);
    });

};

// extend the EventEmitter class using our Meerkat class
util.inherits(Meerkat, EventEmitter);

// Methods to be exported
var exports = module.exports = {};

// we specify that this module is a refrence to the Meerkat class
exports.Meerkat = Meerkat;

// Test method to be removed...
exports.sendMessage = function() {
  console.log('sending a multipart message envelope');
  sock2.send(["{'lagarto': 'hello'}", 'meow!']);
};

//
// Detecting Devices Methods
//
exports.getDevices = function() {

	//Perhaps this should pre cache??

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=7.11.0&value=true', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent")
      }
    })
};

exports.getBatteryLife = function() {

	// return all the remaining battery lifes
	// do some in an arrary like
	return currentBattery = [1,1,1,1,1,1,1,1,1,1];
}

//
// Meat Events
//
exports.dropMeat = function(deviceName) {

	// map device name, and the function to below
	deviceID = feederNameToLagartoID[deviceName];
	functionID = feederFunctionToLagartoDotReference['dropMeat']; //maps to 11.0
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'true';

	console.log("Dropping Meat on: ", deviceName);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent drop meat command")
      }
    })
};

exports.getRemainingMeat = function(deviceName) {

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=7.11.0&value=true', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent")
      }
    })

};

//
// Light Events
//
exports.turnLightOn = function(experimentalLightID) {

	deviceID = indicatorToLagartoID['indicator1'];
	functionID = indicatorFunctionToLagartoDotReference[experimentalLightID];
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'true'; //or perhaps off / on ??

	console.log("Turning Light on: ", experimentalLightID);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent turn ligh on command")
      }
    })

};

exports.turnLightOff = function(experimentalLightID) {

	deviceID = indicatorToLagartoID['indicator1'];
	functionID = indicatorFunctionToLagartoDotReference[experimentalLightID];
	deviceAndFunctionID = deviceID + '.' + functionID;
	value = 'false'; //or perhaps off / on ??

	console.log("Turning Light off on: ", experimentalLightID);
	console.log("Which mapped onto: ", deviceAndFunctionID);

	// Sent command to Lagarto
	request('http://127.0.0.1:8001/values?id=' + deviceAndFunctionID + '&value=' + value, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log("Sent turn light off command")
      }
    })

};<|endoftext|>


<commit_before>var crypto = require("crypto");
var exec = require('child_process').exec;
var fs = require('fs');

helpers = {

  boxFromParam: function (param, res) {
    var box = null
    if(param == null) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "No box param given. Should be in format: '+
        '?box=253723.176600653,6660500.4670516,267723.176600653,6646500.4670516"}');
      return;
    } else {
      param = param.split("|")[0];
      box = param.split(',');
    }
    return box;
  },

  outsizeFromParam: function(param, res) {
    var outsize = null;
    if(param == null) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "No outsize param given. ' +
        'Should be in format: ?outsize=1000,1000  (x,y)"}');
      return false;
    } else {
      outsize = param.split(",");
      if(outsize.length == 1) {
        outsize = [outsize,outsize];
      }
    }
    return outsize;
  },
  numericParams: function(params, res) {
  	var non_number = false;
  	params.forEach(function(i) {
  	      if(!(typeof Number(i) === 'number' &&
              isFinite(Number(i)))) {
  	        non_number = i;
  	        return;
  	      }
  	    }
  	  );
    if(non_number) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "box or outsize param contains non-numerics"}');
    }
    return !non_number;
  },
  fileHash: function(filename, extension) {
    return crypto.createHash('sha1').update(filename).digest('hex')+"."+extension;
  },
  isLoggedIn: function(session) {
    if (!session.oauth_access_token) {
      return false;
    }
    return true;
  },
  generate: function(filename, box, callback) {
    if(fs.existsSync(filename)) {
      console.log("generator: Using cached archive");
      return callback(null, filename);
    }
    var output = "";
    var generator = exec("node "+__dirname+"/../generate.js "+filename+" \""+box.join(',')+"\"", function(err, stdout, stderr) {
      if (err) {
        output += err;
      };
      if (stdout) {
        console.log("generator: ", stdout.toString())
        output += stdout.toString();
      };
      if (stderr) {
        console.log("generator: ", stderr.toString())
        output += stderr.toString();
      }
    });
    generator.on('exit', function(code, signal) {
      if (code != 0) {
        callback("Generator failed with code "+code+"\n <!-- "+output+" -->", null);
      } else {
        callback(null, filename);
      }
    });
  }
};
module.exports = helpers;
<commit_msg>Remove file cache for archive<commit_after>var crypto = require("crypto");
var exec = require('child_process').exec;
var fs = require('fs');

helpers = {

  boxFromParam: function (param, res) {
    var box = null
    if(param == null) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "No box param given. Should be in format: '+
        '?box=253723.176600653,6660500.4670516,267723.176600653,6646500.4670516"}');
      return;
    } else {
      param = param.split("|")[0];
      box = param.split(',');
    }
    return box;
  },

  outsizeFromParam: function(param, res) {
    var outsize = null;
    if(param == null) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "No outsize param given. ' +
        'Should be in format: ?outsize=1000,1000  (x,y)"}');
      return false;
    } else {
      outsize = param.split(",");
      if(outsize.length == 1) {
        outsize = [outsize,outsize];
      }
    }
    return outsize;
  },
  numericParams: function(params, res) {
  	var non_number = false;
  	params.forEach(function(i) {
  	      if(!(typeof Number(i) === 'number' &&
              isFinite(Number(i)))) {
  	        non_number = i;
  	        return;
  	      }
  	    }
  	  );
    if(non_number) {
      res.writeHead(500, { 'Content-Type': 'application/json' });
      res.end('{"error": "box or outsize param contains non-numerics"}');
    }
    return !non_number;
  },
  fileHash: function(filename, extension) {
    return crypto.createHash('sha1').update(filename).digest('hex')+"."+extension;
  },
  isLoggedIn: function(session) {
    if (!session.oauth_access_token) {
      return false;
    }
    return true;
  },
  generate: function(filename, box, callback) {
    var output = "";
    var generator = exec("node "+__dirname+"/../generate.js "+filename+" \""+box.join(',')+"\"", function(err, stdout, stderr) {
      if (err) {
        output += err;
      };
      if (stdout) {
        console.log("generator: ", stdout.toString())
        output += stdout.toString();
      };
      if (stderr) {
        console.log("generator: ", stderr.toString())
        output += stderr.toString();
      }
    });
    generator.on('exit', function(code, signal) {
      if (code != 0) {
        callback("Generator failed with code "+code+"\n <!-- "+output+" -->", null);
      } else {
        callback(null, filename);
      }
    });
  }
};
module.exports = helpers;
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2014-2020 Bjoern Kimminich.
 * SPDX-License-Identifier: MIT
 */

const Prometheus = require('prom-client')
const orders = require('../data/mongodb').orders
const challenges = require('../data/datacache').challenges
const utils = require('../lib/utils')
const config = require('config')
const models = require('../models')
const Op = models.Sequelize.Op

exports.serveMetrics = function serveMetrics (reg) {
  return (req, res, next) => {
    utils.solveIf(challenges.exposedMetricsChallenge, () => { return true })
    res.set('Content-Type', reg.contentType)
    res.end(reg.metrics())
  }
}

exports.observeMetrics = function observeMetrics () {
  const app = config.get('application.metricsAppLabelValue')
  const register = new Prometheus.Registry()
  const intervalCollector = Prometheus.collectDefaultMetrics({ timeout: 5000, register })
  register.setDefaultLabels({ app })

  const challengeMetrics = new Prometheus.Gauge({
    name: `${app}_challenges_solved`,
    help: 'Number of solved challenges grouped by difficulty.',
    labelNames: ['difficulty', 'count']
  })

  const challengeTotalMetrics = new Prometheus.Gauge({
    name: `${app}_challenges_solved_total`,
    help: 'Total number of challenges that have been solved.',
    labelNames: ['count']
  })

  const orderMetrics = new Prometheus.Gauge({
    name: `${app}_orders_placed_total`,
    help: `Number of orders placed in ${config.get('application.name')}.`
  })

  const userMetrics = new Prometheus.Gauge({
    name: `${app}_users_registered`,
    help: 'Number of registered users grouped by customer type.',
    labelNames: ['type']
  })

  const userTotalMetrics = new Prometheus.Gauge({
    name: `${app}_users_registered_total`,
    help: 'Total number of registered users.'
  })

  const walletMetrics = new Prometheus.Gauge({
    name: `${app}_wallet_balance_total`,
    help: 'Total balance of all users\' digital wallets.'
  })

  const complaintMetrics = new Prometheus.Gauge({
    name: `${app}_user_complaints_total`,
    help: 'Unwarranted occurrences of customer lamentation.'
  })

  register.registerMetric(challengeMetrics)
  register.registerMetric(challengeTotalMetrics)
  register.registerMetric(orderMetrics)
  register.registerMetric(userMetrics)
  register.registerMetric(userTotalMetrics)
  register.registerMetric(walletMetrics)
  register.registerMetric(complaintMetrics)

  const updateLoop = setInterval(() => {
    const challengeKeys = Object.keys(challenges)
    challengeTotalMetrics.set({ count: challengeKeys.length }, 0)
    for (let difficulty=1; difficulty<=6; difficulty++) {
      let count = challengeKeys.filter((key) => (challenges[key].difficulty === difficulty)).length
      let solved = challengeKeys.filter((key) => (challenges[key].difficulty === difficulty && challenges[key].solved)).length
      challengeMetrics.set({ difficulty, count }, solved)
      if (solved > 0) challengeTotalMetrics.inc({ count: challengeKeys.length }, solved)
    }

    orders.count({}).then(orders => {
      orderMetrics.set(orders)
    })

    userTotalMetrics.set(0)
    models.User.count({ where: { role: { [Op.eq]: ['customer'] } } }).then(count => {
      userMetrics.set({ type: 'standard' }, count)
      if (count > 0) userTotalMetrics.inc(count)
    })
    models.User.count({ where: { role: { [Op.eq]: 'deluxe' } } }).then(count => {
      userMetrics.set({ type: 'deluxe' }, count)
      if (count > 0) userTotalMetrics.inc(count)
    })

    models.Wallet.sum('balance').then(totalBalance => {
      walletMetrics.set(totalBalance)
    })

    models.Complaint.count().then(count => {
      complaintMetrics.set(count)
    })
  }, 5000)

  return {
    register: register,
    probe: intervalCollector,
    updateLoop: updateLoop
  }
}
<commit_msg>Fix code linting errors<commit_after>/*
 * Copyright (c) 2014-2020 Bjoern Kimminich.
 * SPDX-License-Identifier: MIT
 */

const Prometheus = require('prom-client')
const orders = require('../data/mongodb').orders
const challenges = require('../data/datacache').challenges
const utils = require('../lib/utils')
const config = require('config')
const models = require('../models')
const Op = models.Sequelize.Op

exports.serveMetrics = function serveMetrics (reg) {
  return (req, res, next) => {
    utils.solveIf(challenges.exposedMetricsChallenge, () => { return true })
    res.set('Content-Type', reg.contentType)
    res.end(reg.metrics())
  }
}

exports.observeMetrics = function observeMetrics () {
  const app = config.get('application.metricsAppLabelValue')
  const register = new Prometheus.Registry()
  const intervalCollector = Prometheus.collectDefaultMetrics({ timeout: 5000, register })
  register.setDefaultLabels({ app })

  const challengeMetrics = new Prometheus.Gauge({
    name: `${app}_challenges_solved`,
    help: 'Number of solved challenges grouped by difficulty.',
    labelNames: ['difficulty', 'count']
  })

  const challengeTotalMetrics = new Prometheus.Gauge({
    name: `${app}_challenges_solved_total`,
    help: 'Total number of challenges that have been solved.',
    labelNames: ['count']
  })

  const orderMetrics = new Prometheus.Gauge({
    name: `${app}_orders_placed_total`,
    help: `Number of orders placed in ${config.get('application.name')}.`
  })

  const userMetrics = new Prometheus.Gauge({
    name: `${app}_users_registered`,
    help: 'Number of registered users grouped by customer type.',
    labelNames: ['type']
  })

  const userTotalMetrics = new Prometheus.Gauge({
    name: `${app}_users_registered_total`,
    help: 'Total number of registered users.'
  })

  const walletMetrics = new Prometheus.Gauge({
    name: `${app}_wallet_balance_total`,
    help: 'Total balance of all users\' digital wallets.'
  })

  const complaintMetrics = new Prometheus.Gauge({
    name: `${app}_user_complaints_total`,
    help: 'Unwarranted occurrences of customer lamentation.'
  })

  register.registerMetric(challengeMetrics)
  register.registerMetric(challengeTotalMetrics)
  register.registerMetric(orderMetrics)
  register.registerMetric(userMetrics)
  register.registerMetric(userTotalMetrics)
  register.registerMetric(walletMetrics)
  register.registerMetric(complaintMetrics)

  const updateLoop = setInterval(() => {
    const challengeKeys = Object.keys(challenges)
    challengeTotalMetrics.set({ count: challengeKeys.length }, 0)
    for (let difficulty = 1; difficulty <= 6; difficulty++) {
      const count = challengeKeys.filter((key) => (challenges[key].difficulty === difficulty)).length
      const solved = challengeKeys.filter((key) => (challenges[key].difficulty === difficulty && challenges[key].solved)).length
      challengeMetrics.set({ difficulty, count }, solved)
      if (solved > 0) challengeTotalMetrics.inc({ count: challengeKeys.length }, solved)
    }

    orders.count({}).then(orders => {
      orderMetrics.set(orders)
    })

    userTotalMetrics.set(0)
    models.User.count({ where: { role: { [Op.eq]: ['customer'] } } }).then(count => {
      userMetrics.set({ type: 'standard' }, count)
      if (count > 0) userTotalMetrics.inc(count)
    })
    models.User.count({ where: { role: { [Op.eq]: 'deluxe' } } }).then(count => {
      userMetrics.set({ type: 'deluxe' }, count)
      if (count > 0) userTotalMetrics.inc(count)
    })

    models.Wallet.sum('balance').then(totalBalance => {
      walletMetrics.set(totalBalance)
    })

    models.Complaint.count().then(count => {
      complaintMetrics.set(count)
    })
  }, 5000)

  return {
    register: register,
    probe: intervalCollector,
    updateLoop: updateLoop
  }
}
<|endoftext|>


<commit_before>var express = require('express');
var router = express.Router();

const util = require('../utils/util')

const links = {
    song: '/weapi/v3/song/detail',
    song_url: '/weapi/song/enhance/player/url',
    playlist: '/weapi/v3/playlist/detail'
}

/* GET users listing. */
router.get('/:channel', function(req, res, next) {
    const id = req.query.id
    const br = req.query.br || 999000
    const channel = req.params['channel']

    // console.log(req)
    let config = {
        path: links[channel] || '/weapi/v3/song/detail',
        params: {
            "ids": [id],
            "br": 999000,
            "csrf_token": ""
        }
    }
    switch (channel) {
        case 'playlist':
            config['params'] = {
                "id": id,
                "offset": 0,
                "total": true,
                "limit": 1000,
                "n": 1000,
                "csrf_token": ""
            }
            break;
        case 'song':
            config['params'] = {
                'c': JSON.stringify([{ id: id }]),
                "ids": '[' + id + ']',
                "csrf_token": ""
            }
            break;
        default:
            res.send({
                data: {},
                status: {
                    code: -1,
                    msg: 'no support url. Please set `song` or `playlist`'
                }
            })
            break;
    }
    util.requestServer(config).then(ret => {
        if (channel == 'song') {
            let songs = ret.songs
            if (song && songs.length) {
                config['path'] = links.song_url
                config['params'] = {
                    "ids": [id],
                    "br": br,
                    "csrf_token": ""
                }
                util.requestServer(config).then(rt => {
                    let song = songs[0]
                    song['mp3'] = rt.data[0]
                    res.send({
                        data: song,
                        status: {
                            code: 200,
                            msg: ''
                        }
                    })
                }).catch(ex => {
                    res.send({
                        data: ex,
                        status: {
                            code: -1,
                            msg: 'something happend. Please checked your id or url'
                        }
                    })
                })
            } else {
                res.send({
                    data: {},
                    status: {
                        code: -1,
                        msg: 'sorry, no result, please changed song id.'
                    }
                })
            }
        } else {
            res.send(ret)
        }

    }).catch(err => {
        console.log(err)
        res.send({
            data: err,
            status: {
                code: -1,
                msg: 'something happend. Please checked your id or url'
            }
        })
    })

});

module.exports = router;<commit_msg>fix undefined<commit_after>var express = require('express');
var router = express.Router();

const util = require('../utils/util')

const links = {
    song: '/weapi/v3/song/detail',
    song_url: '/weapi/song/enhance/player/url',
    playlist: '/weapi/v3/playlist/detail'
}

/* GET users listing. */
router.get('/:channel', function(req, res, next) {
    const id = req.query.id
    const br = req.query.br || 999000
    const channel = req.params['channel']
    // console.log(req)
    let config = {
        path: links[channel],
        params: {
            "ids": [id],
            "br": 999000,
            "csrf_token": ""
        }
    }
    switch (channel) {
        case 'playlist':
            config['params'] = {
                "id": id,
                "offset": 0,
                "total": true,
                "limit": 1000,
                "n": 1000,
                "csrf_token": ""
            }
            break;
        case 'song':
            config['params'] = {
                'c': JSON.stringify([{ id: id }]),
                "ids": '[' + id + ']',
                "csrf_token": ""
            }
            break;
        default:
            res.send({
                data: {},
                status: {
                    code: -1,
                    msg: 'no support url. Please set `song` or `playlist`'
                }
            })
            return
            break;
    }
    util.requestServer(config).then(ret => {
        if (channel == 'song') {
            let songs = ret.songs
            if (song && songs.length) {
                config['path'] = links.song_url
                config['params'] = {
                    "ids": [id],
                    "br": br,
                    "csrf_token": ""
                }
                util.requestServer(config).then(rt => {
                    let song = songs[0]
                    song['mp3'] = rt.data[0]
                    res.send({
                        data: song,
                        status: {
                            code: 200,
                            msg: ''
                        }
                    })
                }).catch(ex => {
                    res.send({
                        data: ex,
                        status: {
                            code: -1,
                            msg: 'something happend. Please checked your id or url'
                        }
                    })
                })
            } else {
                res.send({
                    data: {},
                    status: {
                        code: -1,
                        msg: 'sorry, no result, please changed song id.'
                    }
                })
            }
        } else {
            res.send(ret)
        }

    }).catch(err => {
        console.log(err)
        res.send({
            data: err,
            status: {
                code: -1,
                msg: 'something happend. Please checked your id or url'
            }
        })
    })

});

module.exports = router;<|endoftext|>


<commit_before>const teamObject = {
  type: 'object',
  properties: {
    team_id: {
      description: 'team_id',
      type: 'integer',
    },
    rating: {
      description: 'The Elo rating of the team',
      type: 'number',
    },
    wins: {
      description: 'The number of games won by this team',
      type: 'integer',
    },
    losses: {
      description: 'The number of losses by this team',
      type: 'integer',
    },
    last_match_time: {
      description: 'The Unix timestamp of the last match played by this team',
      type: 'integer',
    },
    name: {
      description: 'name',
      type: 'string',
    },
    tag: {
      description: 'The team tag',
      type: 'string',
    },
  },
};
const matchObject = {
  type: 'object',
  properties: {
    match_id: {
      description: 'match_id',
      type: 'integer',
    },
    duration: {
      description: 'duration',
      type: 'integer',
    },
    start_time: {
      description: 'start_time',
      type: 'integer',
    },
    radiant_team_id: {
      description: 'radiant_team_id',
      type: 'integer',
    },
    radiant_name: {
      description: 'radiant_name',
      type: 'string',
    },
    dire_team_id: {
      description: 'dire_team_id',
      type: 'integer',
    },
    dire_name: {
      description: 'dire_name',
      type: 'string',
    },
    leagueid: {
      description: 'leagueid',
      type: 'integer',
    },
    league_name: {
      description: 'league_name',
      type: 'string',
    },
    series_id: {
      description: 'series_id',
      type: 'integer',
    },
    series_type: {
      description: 'series_type',
      type: 'integer',
    },
    radiant_score: {
      description: 'radiant_score',
      type: 'integer',
    },
    dire_score: {
      description: 'dire_score',
      type: 'integer',
    },
    radiant_win: {
      description: 'radiant_win',
      type: 'boolean',
    },
    radiant: {
      description: 'Whether the team/player/hero was on Radiant',
      type: 'boolean',
    },
  },
};
const heroObject = {
  type: 'object',
  properties: {
    id: {
      description: 'id',
      type: 'integer',
    },
    name: {
      description: 'name',
      type: 'string',
    },
    localized_name: {
      description: 'localized_name',
      type: 'string',
    },
    primary_attr: {
      description: 'primary_attr',
      type: 'string',
    },
    attack_type: {
      description: 'attack_type',
      type: 'string',
    },
    roles: {
      type: 'array',
      items: {
        description: 'role',
        type: 'string',
      },
    },
  },
};
const playerObject = {
  type: 'array',
  items: {
    type: 'object',
    properties: {
      account_id: {
        description: 'account_id',
        type: 'integer',
      },
      steamid: {
        description: 'steamid',
        type: 'string',
      },
      avatar: {
        description: 'avatar',
        type: 'string',
      },
      avatarmedium: {
        description: 'avatarmedium',
        type: 'string',
      },
      avatarfull: {
        description: 'avatarfull',
        type: 'string',
      },
      profileurl: {
        description: 'profileurl',
        type: 'string',
      },
      personaname: {
        description: 'personaname',
        type: 'string',
      },
      last_login: {
        description: 'last_login',
        type: 'dateTime',
      },
      full_history_time: {
        description: 'full_history_time',
        type: 'dateTime',
      },
      cheese: {
        description: 'cheese',
        type: 'integer',
      },
      fh_unavailable: {
        description: 'fh_unavailable',
        type: 'boolean',
      },
      loccountrycode: {
        description: 'loccountrycode',
        type: 'string',
      },
      name: {
        description: 'name',
        type: 'string',
      },
      country_code: {
        description: 'country_code',
        type: 'string',
      },
      fantasy_role: {
        description: 'fantasy_role',
        type: 'integer',
      },
      team_id: {
        description: 'team_id',
        type: 'integer',
      },
      team_name: {
        description: 'team_name',
        type: 'string',
      },
      team_tag: {
        description: 'team_tag',
        type: 'string',
      },
      is_locked: {
        description: 'is_locked',
        type: 'boolean',
      },
      is_pro: {
        description: 'is_pro',
        type: 'boolean',
      },
      locked_until: {
        description: 'locked_until',
        type: 'integer',
      },
    },
  },
};

module.exports = {
  matchObject, teamObject, heroObject, playerObject,
};
<commit_msg>Improved majority of object field descriptions. (#1600)<commit_after>const teamObject = {
  type: 'object',
  properties: {
    team_id: {
      description: 'Team\'s identifier',
      type: 'integer',
    },
    rating: {
      description: 'The Elo rating of the team',
      type: 'number',
    },
    wins: {
      description: 'The number of games won by this team',
      type: 'integer',
    },
    losses: {
      description: 'The number of losses by this team',
      type: 'integer',
    },
    last_match_time: {
      description: 'The Unix timestamp of the last match played by this team',
      type: 'integer',
    },
    name: {
      description: 'Team name, eg. \'Newbee\'',
      type: 'string',
    },
    tag: {
      description: 'The team tag/abbreviation',
      type: 'string',
    },
  },
};
const matchObject = {
  type: 'object',
  properties: {
    match_id: {
      description: 'Used to identify individual matches, e.g. 3703866531',
      type: 'integer',
    },
    duration: {
      description: 'Length of the match',
      type: 'integer',
    },
    start_time: {
      description: 'Unix timestamp of when the match began',
      type: 'integer',
    },
    radiant_team_id: {
      description: 'The Radiant\'s team_id',
      type: 'integer',
    },
    radiant_name: {
      description: 'The Radiant\'s team name',
      type: 'string',
    },
    dire_team_id: {
      description: 'The Dire\'s team_id',
      type: 'integer',
    },
    dire_name: {
      description: 'The Dire\'s team name',
      type: 'string',
    },
    leagueid: {
      description: 'Identifier for the league the match took place in',
      type: 'integer',
    },
    league_name: {
      description: 'Name of league the match took place in',
      type: 'string',
    },
    series_id: {
      description: 'Identifier for the series of the match',
      type: 'integer',
    },
    series_type: {
      description: 'Type of series the match was',
      type: 'integer',
    },
    radiant_score: {
      description: 'Number of kills the Radiant team had when the match ended',
      type: 'integer',
    },
    dire_score: {
      description: 'Number of kills the Dire team had when the match ended',
      type: 'integer',
    },
    radiant_win: {
      description: 'Whether or not the Radiant won the match',
      type: 'boolean',
    },
    radiant: {
      description: 'Whether the team/player/hero was on Radiant',
      type: 'boolean',
    },
  },
};
const heroObject = {
  type: 'object',
  properties: {
    id: {
      description: 'Numeric identifier for the hero object',
      type: 'integer',
    },
    name: {
      description: 'Dota hero command name, e.g. \'npc_dota_hero_antimage\'',
      type: 'string',
    },
    localized_name: {
      description: 'Hero name, e.g. \'Anti-Mage\'',
      type: 'string',
    },
    primary_attr: {
      description: 'Hero primary shorthand attribute name, e.g. \'agi\'',
      type: 'string',
    },
    attack_type: {
      description: 'Hero attack type, either \'Melee\' or \'Ranged\'',
      type: 'string',
    },
    roles: {
      type: 'array',
      items: {
        description: 'A hero\'s role in the game',
        type: 'string',
      },
    },
  },
};
const playerObject = {
  type: 'array',
  items: {
    type: 'object',
    properties: {
      account_id: {
        description: 'Player\'s account identifier',
        type: 'integer',
      },
      steamid: {
        description: 'Player\'s steam identifier',
        type: 'string',
      },
      avatar: {
        description: 'Steam picture URL (small picture)',
        type: 'string',
      },
      avatarmedium: {
        description: 'Steam picture URL (medium picture)',
        type: 'string',
      },
      avatarfull: {
        description: 'Steam picture URL (full picture)',
        type: 'string',
      },
      profileurl: {
        description: 'Steam profile URL',
        type: 'string',
      },
      personaname: {
        description: 'Player\'s Steam name',
        type: 'string',
      },
      last_login: {
        description: 'Date and time of last login to OpenDota',
        type: 'dateTime',
      },
      full_history_time: {
        description: 'Date and time of last request to refresh player\'s match history',
        type: 'dateTime',
      },
      cheese: {
        description: 'Amount of dollars the player has donated to OpenDota',
        type: 'integer',
      },
      fh_unavailable: {
        description: 'Whether the refresh of player\' match history failed',
        type: 'boolean',
      },
      loccountrycode: {
        description: 'Player\'s country identifier, e.g. US',
        type: 'string',
      },
      name: {
        description: 'Verified player name, e.g. \'Miracle-\'',
        type: 'string',
      },
      country_code: {
        description: 'Player\'s country code',
        type: 'string',
      },
      fantasy_role: {
        description: 'Player\'s ingame role (core: 1 or support: 2)',
        type: 'integer',
      },
      team_id: {
        description: 'Player\'s team identifier',
        type: 'integer',
      },
      team_name: {
        description: 'Player\'s team name, e.g. \'Evil Geniuses\'',
        type: 'string',
      },
      team_tag: {
        description: 'Player\'s team shorthand tag, e.g. \'EG\'',
        type: 'string',
      },
      is_locked: {
        description: 'Whether the roster lock is active',
        type: 'boolean',
      },
      is_pro: {
        description: 'Whether the player is professional or not',
        type: 'boolean',
      },
      locked_until: {
        description: 'When the roster lock will end',
        type: 'integer',
      },
    },
  },
};

module.exports = {
  matchObject, teamObject, heroObject, playerObject,
};
<|endoftext|>