comparison src/lib/Server.luan @ 16:552d6f944acb

add bump
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 17:34:15 -0600
parents 80105b716a62
children 74277b56ac3c
comparison
equal deleted inserted replaced
15:d0b8e1a8fc69 16:552d6f944acb
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 ipairs = Luan.ipairs or error() 3 local ipairs = Luan.ipairs or error()
4 local Number = require "luan:Number.luan"
5 local long = Number.long or error()
4 local Db = require "site:/lib/Db.luan" 6 local Db = require "site:/lib/Db.luan"
5 local Utils = require "site:/lib/Utils.luan" 7 local Utils = require "site:/lib/Utils.luan"
6 local get_user = Utils.get_user or error() 8 local get_user = Utils.get_user or error()
7 9
8 10
12 doc.type == "server" or error "wrong type" 14 doc.type == "server" or error "wrong type"
13 return Server.new { 15 return Server.new {
14 id = doc.id 16 id = doc.id
15 discord_id = doc.server_discord_id 17 discord_id = doc.server_discord_id
16 owner_discord_id = doc.server_owner_discord_id 18 owner_discord_id = doc.server_owner_discord_id
19 bumped = doc.server_bumped
17 name = doc.name 20 name = doc.name
18 icon = doc.icon 21 icon = doc.icon
19 invite = doc.invite 22 invite = doc.invite
20 } 23 }
21 end 24 end
24 return { 27 return {
25 type = "server" 28 type = "server"
26 id = server.id 29 id = server.id
27 server_discord_id = server.discord_id or error() 30 server_discord_id = server.discord_id or error()
28 server_owner_discord_id = server.owner_discord_id or error() 31 server_owner_discord_id = server.owner_discord_id or error()
32 server_bumped = long(server.bumped)
29 name = server.name or error() 33 name = server.name or error()
30 icon = server.icon or error() 34 icon = server.icon or error()
31 invite = server.invite or error() 35 invite = server.invite or error()
32 } 36 }
33 end 37 end
84 88
85 function Server.get_user_servers() 89 function Server.get_user_servers()
86 return search( "server_owner_discord_id:"..get_user() ) 90 return search( "server_owner_discord_id:"..get_user() )
87 end 91 end
88 92
93 function Server.bumped_sort(s1,s2)
94 return s1.bumped > s2.bumped
95 end
96
89 return Server 97 return Server