<commit_before>from flask_restful import marshal_with,Api,Resource,marshal
from .models import reminder,Reminders
from my_assist.extensions import db,states
from flask import Blueprint,request,jsonify,redirect,url_for
import logging,json
from collections import defaultdict

logging.basicConfig(level=logging.DEBUG)
blueprint=Blueprint("reminder",__name__)
api=Api(blueprint)

class Reminder(Resource):

    @marshal_with(reminder)
    def post(self,state,event):
        data=request.get_json()
        r=Reminders(reminder=data['reminder'],state=state.lower(),event=event.lower())
        r.save()
        return r

    @marshal_with(reminder)
    def get(self,state,event):
        data=Reminders.query.filter(Reminders.state==state.lower() and Reminders.event==event.lower()).all()
        logging.debug(data)
        return data

    def delete(self,state,event):
        rem=request.get_json()['reminder']
        f=Reminders.query.filter(Reminders.reminder==rem and Reminders.state==state.lower() and Reminders.event==event.lower()).first()
        logging.debug(f)
        f.remove()
        return "deleted"

class ReminderList(Resource):
    @marshal_with(reminder)
    def get(self):
        data=Reminders.query.all()
        return data

api.add_resource(Reminder,'/reminder/<string:state>/<string:event>')
api.add_resource(ReminderList,'/reminders')
<commit_msg>Use Session<commit_after>from flask_restful import marshal_with,Api,Resource,marshal
from .models import reminder,Reminders
from my_assist.extensions import db,states
from flask import Blueprint,request,jsonify,redirect,url_for
import logging,json
from collections import defaultdict
from mongoalchemy.session import Session

logging.basicConfig(level=logging.DEBUG)
blueprint=Blueprint("reminder",__name__)
api=Api(blueprint)
from flask import current_app
class Reminder(Resource):

    @marshal_with(reminder)
    def post(self,state,event):
        data=request.get_json()
        r=Reminders(reminder=data['reminder'],state=state.lower(),event=event.lower())
        r.save()
        return r

    @marshal_with(reminder)
    def get(self,state,event):
        with Session.connect('Reminders') as s:
            data = s.query(Reminders).filter(Reminders.state == state.lower() and Reminders.event==event.lower()).all()
            # data=Reminders.query.filter(Reminders.state==state.lower() and Reminders.event==event.lower()).all()
            logging.debug(data)
            return data

    def delete(self,state,event):
        rem=request.get_json()['reminder']
        f=Reminders.query.filter(Reminders.reminder==rem and Reminders.state==state.lower() and Reminders.event==event.lower()).first()
        logging.debug(f)
        f.remove()
        return "deleted"

class ReminderList(Resource):
    @marshal_with(reminder)
    def get(self):
        data=Reminders.query.all()
        return data

api.add_resource(Reminder,'/reminder/<string:state>/<string:event>')
api.add_resource(ReminderList,'/reminders')

{'fraction_non_alphanumeric': 0.12724850099933377, 'fraction_numerical': 0.0, 'mean_word_length': 4.381720430107527, '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': '7464885', 'n_tokens_mistral': 944, 'n_tokens_neox': 943, 'n_words': 150}