コンテンツにスキップ

現在、全3219曲を聴きながらリンク集を作成中のサグラダ・ファミリア サイトです。
情報の誤りやお問い合わせは、管理人 X までお寄せください。
✨ オススメのプレイリストやセトリを教えて下さい ✨

Module:MemberStats

今日も推しが尊いですね。― ハロプロ・サブスク非公式リンク集
2026年2月20日 (金) 11:05時点におけるBarageki (トーク | 投稿記録)による版

local p = {}

-- メンバーの誕生日を一時的に蓄積するテーブル local birthDates = {}

-- 表の各行(MemberRow)から誕生日を受け取って蓄積する関数 function p.addMember(frame)

   local birth = frame.args[1] or frame.args['生年月日順']
   if birth and tonumber(birth) then
       table.insert(birthDates, tonumber(birth))
   end
   return "" -- 画面には何も表示しない

end

-- 蓄積されたデータから統計を出すメイン関数 function p.getStats(frame)

   local mode = frame.args[1] -- "count" か "average"
   local totalAge = 0
   local count = #birthDates
   
   local todayStr = frame:preprocess("2026041")
   local today = tonumber(todayStr)
   if count == 0 then return "0" end
   for _, birth in ipairs(birthDates) do
       local age = math.floor((today - birth) / 10000)
       totalAge = totalAge + age
   end
   if mode == "count" then
       return count
   elseif mode == "average" then
       return string.format("%.2f", totalAge / count)
   end

end

return p