<commit_before>
from ..config import DATABASE_FILE_NAME, DATABASE_FILE_PATH
from ..config import DATABASE_SEARCH_INDEXES_PATH
from ..config import INDEX_REPOSITORY_PATH

from pony.orm   import *
from ponywhoosh import PonyWhoosh

# --------------------------------------------------------------------

pw = PonyWhoosh()

# configurations
pw.indexes_path          = DATABASE_SEARCH_INDEXES_PATH
pw.search_string_min_len = 1
pw.writer_timeout        = 3

db = Database()

@pw.register_model('name', 'description', 'url')
class Library(db.Entity):
    name = PrimaryKey(str)
    localpath = Optional(str)
    description = Optional(str, nullable=True)
    url = Optional(str, nullable=True)
    versions = Set('LibraryVersion')
    appearson = Set('Dependency')
    keywords = Set('Keyword')
    installed = Optional(bool, default=False)

@pw.register_model('version', 'gitURL', 'sha', 'description', 'license')
class LibraryVersion(db.Entity):
    library = Required(Library)
    info_path = Optional(str, nullable=True, default=None)
    name = Optional(str)
    sha = Optional(str)
    valid = Optional(bool, default=False)
    description = Optional(str)
    license = Optional(str)
    testedWith = Set('TestedWith')
    keywords = Set('Keyword')
    requires = Set('Dependency')
    installed = Optional(bool, default=False)

@pw.register_model('word')
class Keyword(db.Entity):
    word = PrimaryKey(str)
    libversions = Set(LibraryVersion)
    libraries = Set(Library)

@pw.register_model('agdaVersion')
class TestedWith(db.Entity):
    agdaVersion = PrimaryKey(str, auto=True)
    libraries = Set(LibraryVersion)

class Dependency(db.Entity):
    id = PrimaryKey(int, auto=True)
    library = Required(Library)
    minVersion = Optional(str, nullable=True)
    maxVersion = Optional(str, nullable=True)
    supporting = Set(LibraryVersion)

db.bind('sqlite', DATABASE_FILE_PATH.as_posix(), create_db=True)
db.generate_mapping(create_tables=True)
<commit_msg>latest bool field for libraryVersion<commit_after>
from ..config import DATABASE_FILE_NAME, DATABASE_FILE_PATH
from ..config import DATABASE_SEARCH_INDEXES_PATH
from ..config import INDEX_REPOSITORY_PATH

from pony.orm   import *
from ponywhoosh import PonyWhoosh

# --------------------------------------------------------------------

pw = PonyWhoosh()

# configurations
pw.indexes_path          = DATABASE_SEARCH_INDEXES_PATH
pw.search_string_min_len = 1
pw.writer_timeout        = 3

db = Database()

@pw.register_model('name', 'description', 'url')
class Library(db.Entity):
    name = PrimaryKey(str)
    localpath = Optional(str)
    description = Optional(str, nullable=True)
    url = Optional(str, nullable=True)
    versions = Set('LibraryVersion')
    appearson = Set('Dependency')
    keywords = Set('Keyword')
    installed = Optional(bool, default=False)

@pw.register_model('version', 'gitURL', 'sha', 'description', 'license')
class LibraryVersion(db.Entity):
    library = Required(Library)
    info_path = Optional(str, nullable=True, default=None)
    name = Optional(str)
    sha = Optional(str)
    valid = Optional(bool, default=False)
    description = Optional(str)
    license = Optional(str)
    testedWith = Set('TestedWith')
    keywords = Set('Keyword')
    requires = Set('Dependency')
    installed = Optional(bool, default=False)
    latest = Optional(bool, default=False)

@pw.register_model('word')
class Keyword(db.Entity):
    word = PrimaryKey(str)
    libversions = Set(LibraryVersion)
    libraries = Set(Library)

@pw.register_model('agdaVersion')
class TestedWith(db.Entity):
    agdaVersion = PrimaryKey(str, auto=True)
    libraries = Set(LibraryVersion)

class Dependency(db.Entity):
    id = PrimaryKey(int, auto=True)
    library = Required(Library)
    minVersion = Optional(str, nullable=True)
    maxVersion = Optional(str, nullable=True)
    supporting = Set(LibraryVersion)

db.bind('sqlite', DATABASE_FILE_PATH.as_posix(), create_db=True)
db.generate_mapping(create_tables=True)

{'fraction_non_alphanumeric': 0.14732366183091547, 'fraction_numerical': 0.0010005002501250625, 'mean_word_length': 3.943139678615575, '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': '3590859', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1217, 'n_words': 257}