Skip to content

Commit

Permalink
⚗️ Update experimental code
Browse files Browse the repository at this point in the history
  • Loading branch information
czy-29 committed Dec 9, 2024
1 parent be09d16 commit 281a272
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tracing-surreal/src/stop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ pub struct Stop<C: Connection> {
formatted_timestamp: String,
}

#[derive(Deserialize)]
struct RID {
id: RecordId,
}

impl<C: Connection> Stop<C> {
pub async fn init(db: Surreal<C>, app: &str) -> surrealdb::Result<Self> {
db.use_db(format!("app-tracing-{}", app)).await?;

#[derive(Debug, Deserialize, Serialize)]
#[derive(Serialize)]
struct SessionRecord {
a_timestamp: DateTime<Local>,
b_access_method: Option<String>,
Expand All @@ -26,11 +31,6 @@ impl<C: Connection> Stop<C> {
g_session_token: Option<Value>,
}

#[derive(Debug, Deserialize, Serialize)]
struct SessionId {
id: RecordId,
}

let a_timestamp = Local::now();
let b_access_method = db.run("session::ac").await?;
let c_record_auth = db.run("session::rd").await?;
Expand All @@ -47,14 +47,14 @@ impl<C: Connection> Stop<C> {
f_session_id,
g_session_token,
};
let id: Option<SessionId> = db
let rid: Option<RID> = db
.create((
"sessions",
Ulid::from_datetime(a_timestamp.into()).to_string(),
))
.content(record)
.await?;
let session_id = id.unwrap().id;
let session_id = rid.unwrap().id;
let formatted_timestamp = a_timestamp.format("%y%m%d-%H%M%S").to_string();

Ok(Self {
Expand Down

0 comments on commit 281a272

Please sign in to comment.