<commit_before>let lastStates = {};
Meteor.startup(function(){
    // {id, state}
    LightStates.find({}).observe({added:manageState, changed:manageState, removed:manageState});
});
function manageState(){
    const states = LightStates.find({},{$sort:{priority:-1}}).fetch();
    // get current state
    var newState = {};
    _(states).each((state)=>{
        if(!state) return;
        _(state.lights).map((state, id)=>{
            if(!id || !state) return;
            lightState = newState[id] || {};
            newState[id] = _(lightState).extend(state);
        });
    });<commit_msg>fix composing light states by ordering by priority<commit_after>let lastStates = {};
Meteor.startup(function(){
    // {id, state}
    LightStates.find({}).observe({added:manageState, changed:manageState, removed:manageState});
});
function manageState(){
    const states = LightStates.find({},{sort:{priority:1}}).fetch();
    // get current state
    var newState = {};
    _(states).each((state)=>{
        if(!state) return;
        _(state.lights).map((state, id)=>{
            if(!id || !state) return;
            lightState = newState[id] || {};
            newState[id] = _(lightState).extend(state);
        });
    });
{'fraction_non_alphanumeric': 0.19070904645476772, 'fraction_numerical': 0.0016299918500407497, 'mean_word_length': 3.1070234113712374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4028928', 'n_tokens_mistral': 368, 'n_tokens_neox': 354, 'n_words': 67}