view src/lib/Db.luan @ 23:e5c77f8d506d default tip

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 15 Sep 2024 10:45:43 -0600
parents 74277b56ac3c
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local new_error = Luan.new_error or error()
local Lucene = require "luan:lucene/Lucene.luan"
local Io = require "luan:Io.luan"
local uri = Io.uri or error()
local Http = require "luan:http/Http.luan"
local Thread = require "luan:Thread.luan"
local Time = require "luan:Time.luan"
local Logging = require "luan:logging/Logging.luan"
local logger = Logging.logger "Db"


local dir = uri("site:/private/local/lucene")

local Db = Lucene.index( dir, {
	log_dir = uri("site:/private/local/lucene_log")
	name = "lucene"
} )

Db.indexed_fields.server_discord_id = Lucene.type.string
Db.indexed_fields.server_owner_discord_id = Lucene.type.string
Db.indexed_fields.server_bumped = Lucene.type.long

function Db.not_in_transaction()
	logger.error(new_error("not in transaction"))
end

if Http.is_serving then
	Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } )
end

return Db