Exemplo n.º 1
0
def get_targets_for_group(group_targets, start, end, average=False):
    if not average:
        return merge(GROUP_AGGREGATE_TARGET_MERGE_DOC, GROUP_TARGET_SPLIT_DOC,
                     group_targets, start, end)

    return merge(GROUP_AVERAGE_TARGET_MERGE_DOC, GROUP_TARGET_SPLIT_DOC,
                 group_targets, start, end)
Exemplo n.º 2
0
def get_base_kpis_for_group(group_kpis, start, end, average=False):
    if not average:
        return merge(GROUP_AGGREGATE_MERGE_DOC, GROUP_SPLIT_DOC, group_kpis,
                     start, end)

    return merge(GROUP_AVERAGE_MERGE_DOC, GROUP_SPLIT_DOC, group_kpis, start,
                 end)
Exemplo n.º 3
0
def get_targets_for_project(project, start, end, skip_select=False):
    if not skip_select:
        return get_merged_timeseries(TargetPeriod, PROPERTY_TARGET_MERGE_DOC,
                                     PROPERTY_TARGET_SPLIT_DOC, project, start,
                                     end)
    return merge(PROPERTY_TARGET_MERGE_DOC, PROPERTY_TARGET_SPLIT_DOC, project,
                 start, end)
Exemplo n.º 4
0
def get_merged_timeseries(cls,
                          merge_doc,
                          split_doc,
                          project,
                          start,
                          end,
                          period_filter=None):
    if period_filter is None:
        period_filter = []
    periods = select(cls.objects.filter(project=project, *period_filter),
                     start, end)
    stripped_periods = []
    for period in periods:
        values = period.get_values()
        values["start"] = period.start
        values["end"] = period.end
        if cls is TargetPeriod:
            # strip `target_`
            keys = list(values.keys())
            for key in keys:
                if "target_" in key:
                    values[key[7:]] = values[key]
                    del values[key]

            print(values)

        stripped_periods.append(values)

    if len(stripped_periods) == 0:
        return None
    result = merge(merge_doc, split_doc, stripped_periods, start, end)
    return result
Exemplo n.º 5
0
def get_base_kpis_for_project(project,
                              start,
                              end,
                              skip_select=False,
                              period_filter=None):
    # Added for ease of testing
    if not skip_select:
        return get_merged_timeseries(Period, PROPERTY_MERGE_DOCUMENT,
                                     PROPERTY_SPLIT_DOCUMENT, project, start,
                                     end, period_filter)
    return merge(PROPERTY_MERGE_DOCUMENT, PROPERTY_SPLIT_DOCUMENT, project,
                 start, end)