{"size": 1532, "ext": "js", "max_stars_repo_path": "kbase-extension/static/kbase/js/widgets/appWidgets2/subdataMethods/samplePropertyHistogram.js", "max_stars_repo_name": "jmchandonia/narrative", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "kbase-extension/static/kbase/js/widgets/appWidgets2/subdataMethods/samplePropertyHistogram.js", "max_issues_repo_name": "jmchandonia/narrative", "max_issues_repo_issues_event_min_datetime": "2015-01-17T00:57:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T11:02:55.000Z", "max_forks_repo_path": "kbase-extension/static/kbase/js/widgets/appWidgets2/subdataMethods/samplePropertyHistogram.js", "max_forks_repo_name": "jmchandonia/narrative", "max_forks_repo_forks_event_min_datetime": "2015-01-17T00:20:25.000Z", "max_forks_repo_forks_event_max_datetime": "2016-09-07T16:46:13.000Z"}
{"max_stars_count": null, "max_issues_count": 356, "max_forks_count": 2, "avg_line_length": 29.4615384615, "max_line_length": 86, "alphanum_fraction": 0.4360313316}
/*global define*/
/*jslint white:true,browser:true*/

define([
], function () {
    'use strict';
    function factory(config) {
        function extractItems(result, params) {            
            if (result.length === 0) {
                return [];
            }
            var rowMetadata = result[0].data.metadata.row_metadata,
                wells = {};
            Object.keys(rowMetadata).forEach(function (rowId) {
                rowMetadata[rowId].forEach(function (prop) {
                    if (prop.category === 'Sample' && prop.property_name === 'Name') {
                        wells[prop.property_value] = prop.property_value;
                    }
                });
            });
            return Object.keys(wells).map(function (wellId) {
                return {
                    id: wellId,
                    text: wellId
                };
            }).sort(function (a, b) {
                return a.text > b.text ? 1 : -1;
            });            
        }

        function getMethod() {
            return {
                params: {
                    referenceObject: 'input_sample_property_matrix',
                    dependencies: ['input_sample_property_matrix']
                },
                included: ["metadata/row_metadata"],
                extractItems: extractItems
            };
        }

        return {
            getMethod: getMethod
        };
    }

    return {
        make: function (config) {
            return factory(config);
        }
    };
});