added the version number to the chat object

This commit is contained in:
dal 2025-04-08 15:42:18 -06:00
parent 7e588d23b3
commit d7023b2f87
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
8 changed files with 17 additions and 0 deletions

View File

@ -114,6 +114,7 @@ pub struct Chat {
pub public_expiry_date: Option<DateTime<Utc>>,
pub most_recent_file_id: Option<Uuid>,
pub most_recent_file_type: Option<String>,
pub most_recent_version_number: Option<i32>,
}
#[derive(Queryable, Insertable, Associations, Debug)]

View File

@ -98,6 +98,7 @@ diesel::table! {
most_recent_file_id -> Nullable<Uuid>,
#[max_length = 255]
most_recent_file_type -> Nullable<Varchar>,
most_recent_version_number -> Nullable<Int4>,
}
}

View File

@ -82,6 +82,7 @@ pub async fn duplicate_chat_handler(
public_expiry_date: None,
most_recent_file_id: source_chat.most_recent_file_id,
most_recent_file_type: source_chat.most_recent_file_type.clone(),
most_recent_version_number: source_chat.most_recent_version_number,
};
// Insert the new chat record

View File

@ -33,6 +33,7 @@ pub struct ChatListItem {
pub last_edited: String,
pub latest_file_id: Option<String>,
pub latest_file_type: Option<String>,
pub latest_version_number: Option<i32>,
}
#[derive(Debug, Serialize, Deserialize)]
@ -58,6 +59,7 @@ struct ChatWithUser {
pub created_by: Uuid,
pub most_recent_file_id: Option<Uuid>,
pub most_recent_file_type: Option<String>,
pub most_recent_version_number: Option<i32>,
// User fields
pub user_name: Option<String>,
pub user_attributes: Value,
@ -128,6 +130,7 @@ pub async fn list_chats_handler(
chats::created_by,
chats::most_recent_file_id,
chats::most_recent_file_type,
chats::most_recent_version_number,
users::name.nullable(),
users::attributes,
))
@ -158,6 +161,7 @@ pub async fn list_chats_handler(
last_edited: chat.updated_at.to_rfc3339(),
latest_file_id: chat.most_recent_file_id.map(|id| id.to_string()),
latest_file_type: chat.most_recent_file_type,
latest_version_number: chat.most_recent_version_number,
}
})
.collect();

View File

@ -2101,6 +2101,7 @@ async fn initialize_chat(
public_expiry_date: None,
most_recent_file_id: None,
most_recent_file_type: None,
most_recent_version_number: None,
};
// Create initial message

View File

@ -0,0 +1,4 @@
-- This file should undo anything in `up.sql`
ALTER TABLE chats
DROP COLUMN most_recent_version_number;

View File

@ -0,0 +1,4 @@
-- Your SQL goes here
ALTER TABLE chats
ADD COLUMN most_recent_version_number INTEGER;

View File

@ -136,6 +136,7 @@ mod tests {
public_expiry_date: None,
most_recent_file_id: None,
most_recent_file_type: None,
most_recent_version_number: None,
};
let mut conn = get_pg_pool().get().await.unwrap();