示例#1
0
def update_dds_primary(val, stack, stack_ts):
    if val is None:
        # * User has cleared the Field dropdown using [x]
        return ([{'label': '<None>', 'value': 0}], -1, True,
                [{'label': '<None>', 'value': 0}], -1, True)

    cur_time = cur_time_ms()
    timedelta_s = (cur_time - stack_ts)/1000
    stale = timedelta_s > 1  # (> 1 seconds since stack last pushed)
    if stale or (stack is None) or (len(stack) == 0):
        print(f'Not using primary stack. Timedelta: {timedelta_s}. Contents: {stack}')
        stackvals = []
        use_stack = False
    else:
        print(f'Using primary stack. Contents: {stack}')
        try:
            stackvals = [int(x) for x in stack.split(',')]
        except Exception as e:
            print("STACK IS:", stack)
            raise e
        assert len(stackvals) == 2, f"stack {stack} is invalid for primary row"
        use_stack = True

    field = primary_fields[val]
    out = []
    trans_ix = stackvals[0] if use_stack else field.default_transformation_ix
    agg_ix = stackvals[1] if use_stack else field.default_aggregation_ix
    out.extend([field.transformation_options, trans_ix, field.transformation_is_disabled])
    out.extend([field.aggregation_options, agg_ix, field.aggregation_is_disabled])

    return out
示例#2
0
    def update_dds(val, stack, stack_ts):
        if val is None or val == 0:
            # EITHER:
            # * User has cleared the Field dropdown using [x]
            # * No variable is selected via the <None> field.
            return ([{
                'label': '<None>',
                'value': 0
            }], -1, True, [{
                'label': '<None>',
                'value': 0
            }], -1, True, [{
                'label': '',
                'value': 1,
                'disabled': True
            }], [])

        cur_time = cur_time_ms()
        timedelta_s = (cur_time - stack_ts) / 1000
        stale = timedelta_s > 1  # (> 1 seconds since stack last pushed)
        if stale or (stack is None) or (len(stack) == 0):
            print(
                f'Not using stack {i}. Timedelta: {timedelta_s}. Contents: {stack}'
            )
            stackvals = []
            use_stack = False
        else:
            print(
                f'Using stack {i}. Timedelta: {timedelta_s}. Contents: {stack}'
            )
            stacksplit = stack.split(',')
            stackvals = [int(x) for x in stacksplit[:2]]
            stackvals.append(stacksplit[2] == 'True')
            assert len(
                stackvals) == 3, f"stack {stack} is invalid for secondary row"
            use_stack = True

        field = secondary_fields[val - 1]
        out = []
        trans_ix = stackvals[
            0] if use_stack else field.default_transformation_ix
        agg_ix = stackvals[1] if use_stack else field.default_aggregation_ix
        chkmark = stackvals[2] if use_stack else False
        out.extend([
            field.transformation_options, trans_ix,
            field.transformation_is_disabled
        ])
        out.extend(
            [field.aggregation_options, agg_ix, field.aggregation_is_disabled])

        chk_disabled = not field.has_dim_lkp
        out.append([{'label': '', 'value': 1, 'disabled': chk_disabled}])
        out.append([1] if chkmark else [])  # checklist value
        # print(out)
        return out
示例#3
0
def update_std_primary(n_clicks, query_ix):

    query = get_query_from_index(query_ix, standard_queries)
    panel_rows = standard_query_to_panel_indices(query, primary_fields,
                                                 secondary_fields,
                                                 as_obj=True)
    # primary variable
    first_row = panel_rows[0]
    trans_id = not_none(first_row.trans_id, 0)
    agg_id = not_none(first_row.agg_id, 0)
    push_to_stack = f'{trans_id},{agg_id}'

    return [first_row.item_id, push_to_stack, cur_time_ms()]
示例#4
0
    def update_std(n_clicks, query_ix):

        query = get_query_from_index(query_ix, standard_queries)
        panel_rows = standard_query_to_panel_indices(query, primary_fields,
                                                     secondary_fields,
                                                     as_obj=True)
        if len(panel_rows) > i+1:
            row = panel_rows[i+1]
            ix = row.item_id
            push_to_stack = f'{row.trans_id},{row.agg_id},{row.perform_lkp}'
        else:
            ix = None
            push_to_stack = ''
        return [ix, push_to_stack, cur_time_ms()]