Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bot/templates/list/event.tera
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ event.details }}
{% endif %}
{% for member in event.members -%}
{% include "list/member" %}
{% include "list/member" -%}
{% endfor %}
⏰ <b>{{ event.time }}</b>
{#- join_prompt -#}
Expand Down
31 changes: 28 additions & 3 deletions entity/src/guardians.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// Guardian
//-------------------------------------------------------------------------------------------------

use {sea_orm::entity::prelude::*, std::fmt};
use {
sea_orm::entity::prelude::*,
std::{fmt, sync::LazyLock},
};

// Old diesel schema for reference:
// table! {
Expand Down Expand Up @@ -84,7 +87,8 @@ impl fmt::Display for Model {
impl Model {
pub fn format_name(&self) -> String {
format!(
"{} (t.me/{}) {}",
"{} {} (t.me/{}) {}",
self.icon(),
self.psn_name,
self.telegram_name,
self.format_destiny_rising_id()
Expand All @@ -94,7 +98,7 @@ impl Model {
pub fn format_destiny_rising_id(&self) -> String {
if let Some(uid) = self.rising_uid {
if let Some(nickname) = &self.rising_nickname {
format!("(D:R uid {} nickname {})", uid, nickname)
format!("(D:R uid {} / {})", uid, nickname)
} else {
format!("(D:R uid {})", uid)
}
Expand All @@ -106,6 +110,27 @@ impl Model {
pub fn names(&self) -> (String, String) {
(self.telegram_name.clone(), self.psn_name.clone())
}

pub fn icon(&self) -> String {
static ICON_POOL: LazyLock<Vec<&str>> = LazyLock::new(|| {
vec![
"💂🏻",
"🕵🏼",
"🧑🏽‍🏭",
"🧑‍💻",
"🧑🏼‍🚒",
"🧑🏾‍🚀",
"🥷🏾",
"🥷🏻",
"🧙🏽",
"🧝🏼",
"🧌",
"🧛🏼",
"🧟",
]
});
ICON_POOL[self.telegram_id.unsigned_abs() as usize % ICON_POOL.len()].into()
}
}

#[cfg(test)]
Expand Down
24 changes: 1 addition & 23 deletions entity/src/plannedactivitymembers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use {
culpa::throws,
sea_orm::entity::prelude::*,
serde::{Deserialize, Serialize},
std::sync::LazyLock,
};

// Old diesel schema for reference:
Expand Down Expand Up @@ -101,28 +100,7 @@ impl Model {
psn_name,
telegram_name,
rising_uid_and_nick,
icon: self.icon(),
icon: guardian.icon(),
}
}

pub fn icon(&self) -> String {
static ICON_POOL: LazyLock<Vec<&str>> = LazyLock::new(|| {
vec![
"💂🏻",
"🕵🏼",
"🧑🏽‍🏭",
"🧑‍💻",
"🧑🏼‍🚒",
"🧑🏾‍🚀",
"🥷🏾",
"🥷🏻",
"🧙🏽",
"🧝🏼",
"🧌",
"🧛🏼",
"🧟",
]
});
ICON_POOL[self.user_id.unsigned_abs() as usize % ICON_POOL.len()].into()
}
}