changeset 10:de0cbf515ef5

remove author_id
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Jun 2022 11:11:00 -0600
parents 9674275019bb
children 3ed1e3f3a53a
files src/lib/Db.luan src/lib/Post.luan src/lib/User.luan
diffstat 3 files changed, 2 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/Db.luan	Thu Jun 30 00:02:28 2022 -0600
+++ b/src/lib/Db.luan	Thu Jun 30 11:11:00 2022 -0600
@@ -12,7 +12,6 @@
 Db.indexed_fields.user_email = Lucene.type.lowercase
 Db.indexed_fields.user_name = Lucene.type.lowercase
 
-Db.indexed_fields.post_author_id = Lucene.type.long
 Db.indexed_fields.post_author_name = Lucene.type.string
 Db.indexed_fields.post_is_root = Lucene.type.string
 Db.indexed_fields.post_root_id = Lucene.type.long
--- a/src/lib/Post.luan	Thu Jun 30 00:02:28 2022 -0600
+++ b/src/lib/Post.luan	Thu Jun 30 11:11:00 2022 -0600
@@ -2,8 +2,6 @@
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
 local set_metatable = Luan.set_metatable or error()
-local Number = require "luan:Number.luan"
-local long = Number.long or error()
 local Time = require "luan:Time.luan"
 local time_now = Time.now or error()
 local Html = require "luan:Html.luan"
@@ -20,7 +18,6 @@
 		content = doc.content
 		date = doc.date
 		author_name = doc.post_author_name
-		author_id = doc.post_author_id
 		root_id = doc.post_root_id
 
 		-- root only
@@ -39,8 +36,7 @@
 		content = post.content or error()
 		date = post.date or time_now()
 		post_author_name = post.author_name or error()
-		post_author_id = long(post.author_id)
-		post_root_id = post.root_id and long(post.root_id)
+		post_root_id = post.root_id
 
 		-- root only
 		subject = post.subject
@@ -55,7 +51,7 @@
 function metatable.__index(post,key)
 	if key == "author" then
 		local User = require "site:/lib/User.luan"
-		return User.get_by_id(post.author_id)
+		return User.get_by_name(post.author_name)
 	end
 	if key == "subject_html" then
 		return post.subject and html_encode(post.subject)
@@ -81,7 +77,6 @@
 				parent_id = post.id
 				content = content
 				author_name = author.name
-				author_id = author.id
 			}
 			post.save()
 			return post
@@ -103,7 +98,6 @@
 			subject = subject or error()
 			content = content
 			author_name = author.name
-			author_id = author.id
 			is_root = true
 		}
 		post.save()
--- a/src/lib/User.luan	Thu Jun 30 00:02:28 2022 -0600
+++ b/src/lib/User.luan	Thu Jun 30 11:11:00 2022 -0600
@@ -64,11 +64,6 @@
 	return user
 end
 
-function User.get_by_id(id)
-	local doc = Db.get_document("id:"..id)
-	return doc and User.from_doc(doc)
-end
-
 function User.get_by_email(email)
 	local doc = Db.get_document("user_email:"..lucene_quote(email))
 	return doc and from_doc(doc)