<commit_before>#!/usr/bin/python
# coding: utf-8

import json
import os
import datetime
import inspect
import time
import zlib
import sys

import hippod.object_hasher
import hippod.api_comm
import hippod.api_shared

from hippod.api_err_obj import *

from hippod import app

from flask import jsonify
from flask import request


def get_all_achievement_data(sha_sum, cont_obj):
    if len(cont_obj['achievements']) <= 0:
        return None

    ret_list = list()
    for achievement in reversed(cont_obj['achievements']):
        data = hippod.api_shared.get_achievement_data_by_sha_id(sha_sum, achievement["id"])

        r = dict()
        for req_attr in ("test-date", "result", "submitter"):
            r[req_attr] = data[req_attr]

        for opt_attr in ("data", "foo"):
            if opt_attr in data:
                r[opt_attr] = data[opt_attr]

        for additional_meta_data in ("id", "date-added"):
            r[additional_meta_data] = achievement[additional_meta_data]

        ret_list.append(r)
    return ret_list


def get_last_attachment_data(sha_sum, cont_obj):
    if len(cont_obj['attachments']) <= 0:
        return None

    last_element_id = cont_obj['attachments'][-1]["id"]
    last_date_added = cont_obj['attachments'][-1]["date-added"]
    last_submitter  = cont_obj['attachments'][-1]["submitter"]

    data = hippod.api_shared.get_attachment_data_by_sha_id(sha_sum, last_element_id)

    r = dict()
    for key, value in data.items():
        r[key] = data[key]

    for i in ('references', 'responsible', 'tags'):
        if i not in data:
            continue
        r[i] = data[i]

    r['id'] = last_element_id
    r['date-added'] = last_date_added<commit_msg>add variety id to achievement meta data<commit_after>#!/usr/bin/python
# coding: utf-8

import json
import os
import datetime
import inspect
import time
import zlib
import sys

import hippod.object_hasher
import hippod.api_comm
import hippod.api_shared

from hippod.api_err_obj import *

from hippod import app

from flask import jsonify
from flask import request


def get_all_achievement_data(sha_sum, cont_obj):
    if len(cont_obj['achievements']) <= 0:
        return None

    ret_list = list()
    for achievement in reversed(cont_obj['achievements']):
        data = hippod.api_shared.get_achievement_data_by_sha_id(sha_sum, achievement["id"])

        r = dict()
        for req_attr in ("test-date", "result", "submitter"):
            r[req_attr] = data[req_attr]

        for opt_attr in ("data", "foo"):
            if opt_attr in data:
                r[opt_attr] = data[opt_attr]

        for additional_meta_data in ("id", "date-added", "variety-id"):
            r[additional_meta_data] = achievement[additional_meta_data]

        ret_list.append(r)
    return ret_list


def get_last_attachment_data(sha_sum, cont_obj):
    if len(cont_obj['attachments']) <= 0:
        return None

    last_element_id = cont_obj['attachments'][-1]["id"]
    last_date_added = cont_obj['attachments'][-1]["date-added"]
    last_submitter  = cont_obj['attachments'][-1]["submitter"]

    data = hippod.api_shared.get_attachment_data_by_sha_id(sha_sum, last_element_id)

    r = dict()
    for key, value in data.items():
        r[key] = data[key]

    for i in ('references', 'responsible', 'tags'):
        if i not in data:
            continue
        r[i] = data[i]

    r['id'] = last_element_id
    r['date-added'] = last_date_added
{'fraction_non_alphanumeric': 0.11563044741429401, 'fraction_numerical': 0.003486345148169669, 'mean_word_length': 3.287671232876712, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3283340', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1134, 'n_words': 266}