annotate src/lib/Db.luan @ 19:b386303be994

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Nov 2023 21:00:37 -0600
parents 74277b56ac3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local new_error = Luan.new_error or error()
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Lucene = require "luan:lucene/Lucene.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Io = require "luan:Io.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local uri = Io.uri or error()
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Http = require "luan:http/Http.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Thread = require "luan:Thread.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Time = require "luan:Time.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Logging = require "luan:logging/Logging.luan"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local logger = Logging.logger "Db"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 local dir = uri("site:/private/local/lucene")
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local Db = Lucene.index( dir, {
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 log_dir = uri("site:/private/local/lucene_log")
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 name = "lucene"
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 } )
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
21 Db.indexed_fields.server_discord_id = Lucene.type.string
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
22 Db.indexed_fields.server_owner_discord_id = Lucene.type.string
17
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 14
diff changeset
23 Db.indexed_fields.server_bumped = Lucene.type.long
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
24
3
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 function Db.not_in_transaction()
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 logger.error(new_error("not in transaction"))
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 end
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 if Http.is_serving then
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } )
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 end
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32
43814e9f5802 add config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 return Db