// Arrakis uses the existing Arrakduin world ID. A parent deed controller is // not the local sietch owner and does not acquire its Council seat. export const NAIB_SEATS_SQL=`SELECT c.id clan_id,c.name clan_name,c.tag,c.owner_id user_id,a.username,a.display_name,l.minecraft_uuid FROM site_clans c JOIN site_clan_members m ON m.clan_id=c.id AND m.user_id=c.owner_id AND m.clan_role='owner' JOIN site_game_links l ON l.user_id=m.user_id AND LOWER(l.minecraft_uuid)=LOWER(m.minecraft_uuid) JOIN site_accounts a ON a.id=c.owner_id WHERE c.active=1 AND c.home_world='arrakduin' AND a.password_hash NOT LIKE '!%' AND a.role NOT IN ('official_account','memorial')`; export async function naibSeats(db){return db.query(NAIB_SEATS_SQL+' ORDER BY c.id');} export async function currentNaib(db,userId,{lock=false}={}){ const rows=await db.query(NAIB_SEATS_SQL+' AND c.owner_id=? ORDER BY c.id'+(lock?' FOR UPDATE':''),[userId]); // Clan membership currently permits one home clan; ambiguity must fail closed. return rows.length===1?rows[0]:null; }