<commit_before>import uuid
import urllib

from datetime import datetime
from functools import wraps, update_wrapper

import requests

from flask import g, request, abort, make_response, Response
from flask_restplus import Resource, fields

from werkzeug.datastructures import FileStorage

from pyinfraboxutils.ibflask import auth_token_required, OK
from pyinfraboxutils.ibrestplus import api
from pyinfraboxutils.storage import storage

ns = api.namespace('api/v1/projects', description='Project related operations')

def nocache(view):
    @wraps(view)
    def no_cache(*args, **kwargs):
        response = make_response(view(*args, **kwargs))
        response.headers['Surrogate-Control'] = 'no-store'
        response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, proxy-revalidate'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'
        response.last_modified = datetime.now()
        response.add_etag()
        return response

    return update_wrapper(no_cache, view)

def get_badge(url):
    resp = requests.get(url)

    excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
    headers = [(name, value) for (name, value) in resp.raw.headers.items()
               if name.lower() not in excluded_headers]

    response = Response(resp.content, resp.status_code, headers)
    return response

project_model = api.model('ProjectModel', {
    'id': fields.String,
    'name': fields.String,
    'type': fields.String,
    'public': fields.Boolean
})

@ns.route('/<project_id>')
class Project(Resource):

    @auth_token_required(['user', 'project'])
    @api.marshal_with(project_model)
    def get(self, project_id):
        p = g.db.execute_one_dict('''
            SELECT name, id, type, public
            FROM project
            WHERE id = %s
        ''', [project_id])
        return p

@ns.route('/<project_id>/state.svg')
@api.doc(security=[])
class State(Resource):

    @nocache<commit_msg>fix badge caching<commit_after>import uuid
import urllib

from datetime import datetime
from functools import wraps, update_wrapper

import requests

from flask import g, jsonify, request, abort, make_response, Response
from flask_restplus import Resource, fields

from werkzeug.datastructures import FileStorage

from pyinfraboxutils.ibflask import auth_token_required, OK
from pyinfraboxutils.ibrestplus import api
from pyinfraboxutils.storage import storage

ns = api.namespace('api/v1/projects', description='Project related operations')

def nocache(view):
    @wraps(view)
    def no_cache(*args, **kwargs):
        response = make_response(view(*args, **kwargs))
        response.headers['Surrogate-Control'] = 'no-store'
        response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, proxy-revalidate'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'
        response.last_modified = datetime.now()
        response.add_etag()
        return response

    return update_wrapper(no_cache, view)

def get_badge(url):
    resp = requests.get(url)

    excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
    headers = [(name, value) for (name, value) in resp.raw.headers.items()
               if name.lower() not in excluded_headers]

    response = Response(resp.content, resp.status_code, headers)
    return response

project_model = api.model('ProjectModel', {
    'id': fields.String,
    'name': fields.String,
    'type': fields.String,
    'public': fields.Boolean
})

def nocache(view):
    @wraps(view)
    def no_cache(*args, **kwargs):
        response = make_response(view(*args, **kwargs))
        response.headers['Surrogate-Control'] = 'no-store'
        response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, proxy-revalidate'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'
        response.last_modified = datetime.now()
        response.add_etag()
        return response

    return update_wrapper(no_cache, view)

def get_badge(url):
    resp = requests.get(url)

    excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
    headers = [(name, value) for (name, value) in resp.raw.headers.items()
               if name.lower() not in excluded_headers]

    response = Response(resp.content, resp.status_code, headers)
    return response

@ns.route('/<project_id>')
class Project(Resource):

    @auth_token_required(['user', 'project'])
    @api.marshal_with(project_model)
    def get(self, project_id):
        p = g.db.execute_one_dict('''
            SELECT name, id, type, public
            FROM project
            WHERE id = %s
        ''', [project_id])
        return p

@ns.route('/<project_id>/state.svg')
@api.doc(security=[])
class State(Resource):

    @nocache
{'fraction_non_alphanumeric': 0.12672904800650936, 'fraction_numerical': 0.0010170870626525631, 'mean_word_length': 3.6169014084507043, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2739882', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1466, 'n_words': 348}