Exemplo n.º 1
0
    def __init__(self, raw_dict, metric_name):

        self.config = configs.metrics()[metric_name]
        self.metric_name = metric_name

        # temporary for until we get this from the db via sqlalchemy
        del raw_dict["static_meta"]
        for k, v in raw_dict.iteritems():
            setattr(self, k, v)
Exemplo n.º 2
0
    def __init__(self, raw_dict, metric_name):

        self.config = configs.metrics()[metric_name]
        self.metric_name = metric_name

        # temporary for until we get this from the db via sqlalchemy
        del raw_dict["static_meta"]
        for k, v in raw_dict.iteritems():
            setattr(self, k, v)
Exemplo n.º 3
0
def make_mendeley_metric(tiid, snaps, product_created):
    metric = MendeleyDisciplineMetric(tiid, "mendeley", "discipline",
                                      configs.metrics()["mendeley:discipline"])
    metric.add_snaps_from_list(snaps)
    metric.product_create_date = arrow.get(product_created)

    if len(metric.snaps):
        return metric
    else:
        return None
Exemplo n.º 4
0
def get_metrics_by_engagement(products, engagement):
    matching_metrics = []
    all_possible_metrics_config_dicts = configs.metrics().values()

    for product in products:
        for config_dict in all_possible_metrics_config_dicts:
            if config_dict["engagement_type"]==engagement:
                provider = config_dict["provider"]
                interaction = config_dict["interaction"]
                metric = product.get_metric_by_name(provider, interaction)
                if metric:
                    matching_metrics.append(metric)
    return matching_metrics
Exemplo n.º 5
0
def make_mendeley_metric(tiid, snaps, product_created):
    metric = MendeleyDisciplineMetric(
        tiid,
        "mendeley",
        "discipline",
        configs.metrics()["mendeley:discipline"]
    )
    metric.add_snaps_from_list(snaps)
    metric.product_create_date = arrow.get(product_created)

    if len(metric.snaps):
        return metric
    else:
        return None
def make_product_list_cards(products, card_class, url_slug=None):
    cards = []
    all_possible_metrics_config_dicts = configs.metrics().values()

    for metric_config in all_possible_metrics_config_dicts:
        provider = metric_config["provider"]
        interaction = metric_config["interaction"]

        if "citations" in interaction:
            continue  # we aren't allowed to accumulate scopus, don't want to accumulate PMC ciations

        if card_class.would_generate_a_card(products, provider, interaction):
            new_card = card_class(products, provider, interaction, url_slug)
            cards.append(new_card)

    return cards
Exemplo n.º 7
0
def make_metrics_list(tiid, snaps, product_created):
    metrics = []

    for fully_qualified_metric_name, my_config in configs.metrics().iteritems(
    ):
        my_provider, my_interaction = fully_qualified_metric_name.split(":")

        if Metric.test(my_provider, my_interaction, snaps):

            my_metric = Metric(tiid, my_provider, my_interaction, my_config)

            my_metric.add_snaps_from_list(snaps)

            my_metric.product_create_date = arrow.get(product_created)
            metrics.append(my_metric)

    return metrics
Exemplo n.º 8
0
def make_profile_new_metrics_cards(profile, timestamp=None):
    if not timestamp:
        timestamp = datetime.datetime.utcnow()

    cards = []
    all_possible_metrics_config_dicts = configs.metrics().values()

    for metric_config in all_possible_metrics_config_dicts:
        provider = metric_config["provider"]
        interaction = metric_config["interaction"]

        if "citations" in interaction:
            continue  # we aren't allowed to accumulate scopus, don't want to accumulate PMC ciations

        if ProfileNewMetricCard.would_generate_a_card(profile, provider, interaction):
            new_card = ProfileNewMetricCard(profile, provider, interaction)
            cards.append(new_card)

    return cards
Exemplo n.º 9
0
def make_profile_new_metrics_cards(profile, timestamp=None):
    if not timestamp:
        timestamp = datetime.datetime.utcnow()

    cards = []
    all_possible_metrics_config_dicts = configs.metrics().values()

    for metric_config in all_possible_metrics_config_dicts:
        provider = metric_config["provider"]
        interaction = metric_config["interaction"]

        if "citations" in interaction:
            continue  # we aren't allowed to accumulate scopus, don't want to accumulate PMC ciations

        if ProfileNewMetricCard.would_generate_a_card(profile, provider,
                                                      interaction):
            new_card = ProfileNewMetricCard(profile, provider, interaction)
            cards.append(new_card)

    return cards
Exemplo n.º 10
0
def make_metrics_list(tiid, snaps, product_created):
    metrics = []

    for fully_qualified_metric_name, my_config in configs.metrics().iteritems():
        my_provider, my_interaction = fully_qualified_metric_name.split(":")

        if Metric.test(my_provider, my_interaction, snaps):

            my_metric = Metric(
                tiid,
                my_provider,
                my_interaction,
                my_config)

            my_metric.add_snaps_from_list(snaps)

            my_metric.product_create_date = arrow.get(product_created)
            metrics.append(my_metric)

    return metrics