<commit_before>{ Datomic } = require src + 'datomic'
{ edn, find } = require src + 'edn'
schema = require './schema'

describe 'Sample with movies', ->

  imdb = new Datomic 'localhost', 8888, 'db', 'imdb'

  add_movie = (id, title, done) ->
    imdb.transact [[':db/add', id, ':title', title]], ->
      done()

  before (done) ->
    
    imdb.createDatabase ->
      imdb.transact schema.movies, ->
        add_movie 1, 'pulp fiction', ->
          add_movie 2, 'fight club', ->
            add_movie 3, 'lola rennt', ->
              add_movie 4, 'trainspotting', ->
                done()

  it 'should return all', (done) ->

    imdb.q [':find', '?m', ':where', ['?m', ':title']], (err, movies)->
      movies.length.should.equal 4
      done()
    
  it 'should find trainspotting', (done) ->
    
    imdb.q find('?m').where('?m', ':title', 'trainspotting'), (err, movies) ->
      imdb.entity movies[0][0], (err, movie) ->
        movie.title.should.equal 'trainspotting'
        done()<commit_msg>added next test ... sorta ... to b continue<commit_after>{ Datomic } = require src + 'datomic'
{ edn, find } = require src + 'edn'
schema = require './schema'

describe 'Sample with movies', ->

  imdb = new Datomic 'localhost', 8888, 'db', 'imdb'

  add_movie = (id, title, done) ->
    imdb.transact [[':db/add', id, ':title', title]], ->
      done()

  before (done) ->
    
    imdb.createDatabase ->
      imdb.transact schema.movies, ->
        add_movie 1, 'pulp fiction', ->
          add_movie 2, 'fight club', ->
            add_movie 3, 'lola rennt', ->
              add_movie 4, 'trainspotting', ->
                done()

  it 'should return all', (done) ->

    imdb.q [':find', '?m', ':where', ['?m', ':title']], (err, movies)->
      movies.length.should.equal 4
      done()
    
  it 'should find trainspotting', (done) ->
    
    imdb.q find('?m').where('?m', ':title', 'trainspotting'), (err, movies) ->
      imdb.entity movies[0][0], (err, movie) ->
        movie.title.should.equal 'trainspotting'
        done()
  
  it 'should find the highest rated movie', (done) ->
    
    imdb.q find('?t').where('?m', ':title', '?t'), (err, movies) ->
      console.log movies
      done()
  
{'fraction_non_alphanumeric': 0.1930536761389265, 'fraction_numerical': 0.009923319801533603, 'mean_word_length': 2.3504531722054383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '183254', 'n_tokens_mistral': 795, 'n_tokens_neox': 751, 'n_words': 200}