<commit_before>from datetime import datetime
from flask import render_template, redirect, \
    url_for, flash, abort, current_app, request
from flask.ext.login import current_user, login_required

from . import main
from .. import db
from .forms import NoteForm, ShareForm, \
    NotebookForm, SearchForm
from ..email import send_email
from ..models import User, Note, Tag, Notebook


@main.route('/', methods=['GET', 'POST'])
def index():
    if current_user.is_authenticated():
        notes = Note.query.filter_by(
            author_id=current_user.id,
            is_deleted=False).order_by(
            Note.is_favorite.desc(),
            Note.updated_date.desc()).all()
        return render_template('app/app.html', notes=notes)
    else:
        stats = []
        users = User.query.count()
        stats.append(users)
        notes = Note.query.count()
        stats.append(notes)
        return render_template('index.html', stats=stats)


@main.route('/add', methods=['GET', 'POST'])
@login_required
def add():
    form = NoteForm()
    form.notebook.choices = [
        (n.id, n.title) for n in
        Notebook.query.filter_by(
            author_id=current_user.id).all()]
    if form.validate_on_submit():
        note = Note(
            title=form.title.data,
            body=form.body.data,
            body_html=form.body_html.data,
            notebook_id=form.notebook.data,
            author=current_user._get_current_object())
        db.session.add(note)
        tags = []
        if not len(form.tags.data) == 0:
            for tag in form.tags.data.split(','):
                tags.append(tag.replace(" ", ""))
            note.str_tags = (tags)<commit_msg>[BUGFIX] Adding Notes without Tags saves the note<commit_after>from datetime import datetime
from flask import render_template, redirect, \
    url_for, flash, abort, current_app, request
from flask.ext.login import current_user, login_required

from . import main
from .. import db
from .forms import NoteForm, ShareForm, \
    NotebookForm, SearchForm
from ..email import send_email
from ..models import User, Note, Tag, Notebook


@main.route('/', methods=['GET', 'POST'])
def index():
    if current_user.is_authenticated():
        notes = Note.query.filter_by(
            author_id=current_user.id,
            is_deleted=False).order_by(
            Note.is_favorite.desc(),
            Note.updated_date.desc()).all()
        return render_template('app/app.html', notes=notes)
    else:
        stats = []
        users = User.query.count()
        stats.append(users)
        notes = Note.query.count()
        stats.append(notes)
        return render_template('index.html', stats=stats)


@main.route('/add', methods=['GET', 'POST'])
@login_required
def add():
    form = NoteForm()
    form.notebook.choices = [
        (n.id, n.title) for n in
        Notebook.query.filter_by(
            author_id=current_user.id).all()]
    if form.validate_on_submit():
        note = Note(
            title=form.title.data,
            body=form.body.data,
            body_html=form.body_html.data,
            notebook_id=form.notebook.data,
            author=current_user._get_current_object())
        db.session.add(note)
        db.session.commit()
        tags = []
        if not len(form.tags.data) == 0:
            for tag in form.tags.data.split(','):
                tags.append(tag.replace(" ", ""))
            note.str_tags = (tags)
{'fraction_non_alphanumeric': 0.12775842044134728, 'fraction_numerical': 0.0005807200929152149, 'mean_word_length': 2.4210526315789473, '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': '869225', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1030, 'n_words': 223}