This commit is contained in:
Elijah McMorris 2023-12-15 00:45:08 -08:00
parent 44b66d43c1
commit 8b3311ff21
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
6 changed files with 65 additions and 12 deletions

View file

@ -1,8 +1,15 @@
use dotenv_codegen::dotenv;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::env;
use surrealdb::sql::Thing;
use wikidata::{ClaimValue, ClaimValueData, Entity, Lang, Pid, WikiId};
lazy_static! {
static ref WIKIDATA_LANG: String = env::var("WIKIDATA_LANG")
.expect("WIKIDATA_LANG not set")
.to_string();
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ClaimData {
Thing(Thing),
@ -117,7 +124,7 @@ fn get_id_entity(entity: &Entity) -> Thing {
fn get_name(entity: &Entity) -> String {
entity
.labels
.get(&Lang(dotenv!("WIKIDATA_LANG").to_string()))
.get(&Lang(WIKIDATA_LANG.to_string()))
.expect("No label found")
.to_string()
}
@ -125,6 +132,6 @@ fn get_name(entity: &Entity) -> String {
fn get_description(entity: &Entity) -> Option<String> {
entity
.descriptions
.get(&Lang(dotenv!("WIKIDATA_LANG").to_string()))
.get(&Lang(WIKIDATA_LANG.to_string()))
.cloned()
}