Mercurial Hosting > chat
comparison src/lib/Db.luan @ 53:9298b04607ae
add unread
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 03 Mar 2025 19:39:30 -0700 |
parents | f9e6a4cc4f7d |
children | d21ae4920aac |
comparison
equal
deleted
inserted
replaced
52:c3fabb21b6c4 | 53:9298b04607ae |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local new_error = Luan.new_error or error() | 3 local new_error = Luan.new_error or error() |
4 local ipairs = Luan.ipairs or error() | |
4 local Lucene = require "luan:lucene/Lucene.luan" | 5 local Lucene = require "luan:lucene/Lucene.luan" |
5 local Io = require "luan:Io.luan" | 6 local Io = require "luan:Io.luan" |
6 local uri = Io.uri or error() | 7 local uri = Io.uri or error() |
7 local Http = require "luan:http/Http.luan" | 8 local Http = require "luan:http/Http.luan" |
8 local Thread = require "luan:Thread.luan" | 9 local Thread = require "luan:Thread.luan" |
23 | 24 |
24 Db.indexed_fields.chat_user_ids = Lucene.type.long | 25 Db.indexed_fields.chat_user_ids = Lucene.type.long |
25 Db.indexed_fields.chat_updated = Lucene.type.long | 26 Db.indexed_fields.chat_updated = Lucene.type.long |
26 | 27 |
27 Db.indexed_fields.post_chat_id = Lucene.type.long | 28 Db.indexed_fields.post_chat_id = Lucene.type.long |
29 Db.indexed_fields.post_date = Lucene.type.long | |
30 | |
31 Db.indexed_fields.chatuser_id = Lucene.type.string | |
28 | 32 |
29 function Db.not_in_transaction() | 33 function Db.not_in_transaction() |
30 logger.error(new_error("not in transaction")) | 34 logger.error(new_error("not in transaction")) |
31 end | 35 end |
32 | 36 |
33 Db.update{ | 37 Db.update{ |
38 [1] = function() | |
39 local docs = Db.search("type:post",1,1000000) | |
40 for _, doc in ipairs(docs) do | |
41 doc.post_date = doc.post_date or doc.date | |
42 Db.save(doc) | |
43 end | |
44 end | |
34 } | 45 } |
35 | 46 |
36 if Http.is_serving then | 47 if Http.is_serving then |
37 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } ) | 48 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } ) |
38 end | 49 end |