<commit_before># bultin library

# external libraries
from sanic import Sanic
from sanic.response import text, json
from condor.dbutil import requires_db
from condor.models import Bibliography, RankingMatrix, \
    TermDocumentMatrix, Document


app = Sanic(__name__)


@app.route("/ranking", methods=["GET"])
@requires_db
async def list_rankings(db, request):
    ranking_matrices = [
        {
            "eid": matrix.eid,
            "kind": matrix.kind,
            "build_options": matrix.build_options,
            "ranking_matrix_path": matrix.ranking_matrix_path
        }
        for matrix in RankingMatrix.list(db)
    ]
    return json(ranking_matrices)


@app.route("/bibliography")
@requires_db
async def list_bibliographies(db, request):
    bibliographies = [
        {
            "eid": bib.eid,
            "description": bib.description,
            "created": bib.created,
            "modified": bib.modified
        }
        for bib in Bibliography.list(db)
    ]
    return json(bibliographies)


@app.route("/bibliography/<eid>")
@requires_db
async def bibliography(db, request, eid):
    """
    Bibliography associated with a blibliography eid
    """
    bibliography = Bibliography.find_by_eid(db, eid)

    if not bibliography:
        return json({})

    return json(
        {<commit_msg>Closes #23, add status for a not existent bibliography<commit_after># bultin library

# external libraries
from sanic import Sanic
from sanic.response import text, json
from condor.dbutil import requires_db
from condor.models import Bibliography, RankingMatrix, \
    TermDocumentMatrix, Document


app = Sanic(__name__)


@app.route("/ranking", methods=["GET"])
@requires_db
async def list_rankings(db, request):
    ranking_matrices = [
        {
            "eid": matrix.eid,
            "kind": matrix.kind,
            "build_options": matrix.build_options,
            "ranking_matrix_path": matrix.ranking_matrix_path
        }
        for matrix in RankingMatrix.list(db)
    ]
    return json(ranking_matrices)


@app.route("/bibliography")
@requires_db
async def list_bibliographies(db, request):
    bibliographies = [
        {
            "eid": bib.eid,
            "description": bib.description,
            "created": bib.created,
            "modified": bib.modified
        }
        for bib in Bibliography.list(db)
    ]
    return json(bibliographies)


@app.route("/bibliography/<eid>")
@requires_db
async def bibliography(db, request, eid):
    """
    Bibliography associated with a blibliography eid
    """
    bibliography = Bibliography.find_by_eid(db, eid)

    if not bibliography:
        return json(
            {
                "message": "The especified eid is not found on database"
            },
            status=404
        )

    return json(
        {
{'fraction_non_alphanumeric': 0.1010280042538107, 'fraction_numerical': 0.001772421127259837, 'mean_word_length': 2.572151898734177, 'pattern_counts': {'":': 17, '<': 5, '<?xml version=': 0, '>': 5, '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': '426653', 'n_tokens_mistral': 872, 'n_tokens_neox': 819, 'n_words': 204}