<commit_before>from wtforms import Form, BooleanField, StringField, PasswordField, SelectField, TextAreaField, DateTimeField, validators
from wwag import app, database

def all_players():
  with app.app_context():
    players = database.execute("SELECT PlayerID, FirstName, LastName FROM Player").fetchall()
    return [(p['PlayerID'], "%s %s" % (p['FirstName'],p["LastName"])) for p in players]

class LoginForm(Form):
  email = StringField('Email', [validators.Email()])
  password = PasswordField('Password', [validators.Length(min=6, max=128)])

class InstanceRunForm(Form):
  supervisor_id = SelectField('Supervisor', coerce=int, choices=all_players())
  name = StringField('Name', [validators.Length(min=3, max=45)])
  recorded_time = DateTimeField('Recorded Time')
  category_name = SelectField('Category', choices=[(c, c) for c in ["Just for Fun", "Achievement Attempt", "Role Playing", "Team Challenge"]])

class AddInstanceRunPlayerForm(Form):
  player_id = SelectField('Player', coerce=int, choices=all_players())
  performance_notes = TextAreaField('Performance Notes', [validators.optional(), validators.length(max=200)])<commit_msg>return empty for database errors in forms<commit_after>from wtforms import Form, BooleanField, StringField, PasswordField, SelectField, TextAreaField, DateTimeField, validators
from wwag import app, database

def all_players():
  with app.app_context():
    try:
      players = database.execute("SELECT PlayerID, FirstName, LastName FROM Player").fetchall()
      return [(p['PlayerID'], "%s %s" % (p['FirstName'],p["LastName"])) for p in players]
    except:
      return []

class LoginForm(Form):
  email = StringField('Email', [validators.Email()])
  password = PasswordField('Password', [validators.Length(min=6, max=128)])

class InstanceRunForm(Form):
  supervisor_id = SelectField('Supervisor', coerce=int, choices=all_players())
  name = StringField('Name', [validators.Length(min=3, max=45)])
  recorded_time = DateTimeField('Recorded Time')
  category_name = SelectField('Category', choices=[(c, c) for c in ["Just for Fun", "Achievement Attempt", "Role Playing", "Team Challenge"]])

class AddInstanceRunPlayerForm(Form):
  player_id = SelectField('Player', coerce=int, choices=all_players())
  performance_notes = TextAreaField('Performance Notes', [validators.optional(), validators.length(max=200)])
{'fraction_non_alphanumeric': 0.14570097416349004, 'fraction_numerical': 0.00847098686997035, 'mean_word_length': 7.061433447098976, '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': '600369', 'n_tokens_mistral': 725, 'n_tokens_neox': 700, 'n_words': 178}