<commit_before># -*- coding: utf-8 -*-
import uuid

from flask import Blueprint
from flask_restful import abort, Api, marshal_with, Resource

from .extensions import db
from .models import Tag, Category, URL
from .serializers import (
    tag_fields, category_fields, url_fields,
    url_parser_create, url_parser_update
)

api_bp = Blueprint('api', __name__)
api = Api(api_bp)


def get_instance_or_404_by_id(cls, id):
    try:
        id = str(id)
        uuid.UUID(id)
    except ValueError:
        abort(404)
    instance = db.session.query(cls).get(id)
    if instance is None:
        abort(404)
    return instance


class TagListView(Resource):
    @marshal_with(tag_fields)
    def get(self):
        return Tag.query.order_by(Tag.url_number.desc()).all()


class CategoryListView(Resource):
    @marshal_with(category_fields)
    def get(self):
        return Category.query.order_by(Category.url_number.desc()).all()


class URLListView(Resource):
    @marshal_with(url_fields)
    def get(self):
        return URL.query.order_by(URL.created_at).all()

    @marshal_with(url_fields)
    def post(self):
        args = url_parser_create.parse_args()
        instance = URL.new_url(title=args['title'], url=args['url'],
                               starred=args['starred'],
                               tags_str=args['tags'],
                               categories_str=args['categories'])
        db.session.add(instance)
        db.session.commit()
        return instance, 201, {
            'Location': api.url_for(
                URLDetailView, id=instance.id, _external=True
            )
        }

<commit_msg>order by update_at desc<commit_after># -*- coding: utf-8 -*-
import uuid

from flask import Blueprint
from flask_restful import abort, Api, marshal_with, Resource

from .extensions import db
from .models import Tag, Category, URL
from .serializers import (
    tag_fields, category_fields, url_fields,
    url_parser_create, url_parser_update
)

api_bp = Blueprint('api', __name__)
api = Api(api_bp)


def get_instance_or_404_by_id(cls, id):
    try:
        id = str(id)
        uuid.UUID(id)
    except ValueError:
        abort(404)
    instance = db.session.query(cls).get(id)
    if instance is None:
        abort(404)
    return instance


class TagListView(Resource):
    @marshal_with(tag_fields)
    def get(self):
        return Tag.query.order_by(Tag.url_number.desc()).all()


class CategoryListView(Resource):
    @marshal_with(category_fields)
    def get(self):
        return Category.query.order_by(Category.url_number.desc()).all()


class URLListView(Resource):
    @marshal_with(url_fields)
    def get(self):
        return URL.query.order_by(URL.updated_at.desc()).all()

    @marshal_with(url_fields)
    def post(self):
        args = url_parser_create.parse_args()
        instance = URL.new_url(title=args['title'], url=args['url'],
                               starred=args['starred'],
                               tags_str=args['tags'],
                               categories_str=args['categories'])
        db.session.add(instance)
        db.session.commit()
        return instance, 201, {
            'Location': api.url_for(
                URLDetailView, id=instance.id, _external=True
            )
        }


{'fraction_non_alphanumeric': 0.11219215567041654, 'fraction_numerical': 0.007905138339920948, 'mean_word_length': 2.5799782372143634, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6135998', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1002, 'n_words': 203}