This PR adds a REST API to the collab server for searching and downloading extensions. Previously, we had implemented this API in zed.dev directly, but this implementation is better, because we use the collab database to store the download counts for extensions. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Conrad <conrad@zed.dev>
28 lines
690 B
Rust
28 lines
690 B
Rust
use crate::db::ExtensionId;
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "extensions")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: ExtensionId,
|
|
pub external_id: String,
|
|
pub name: String,
|
|
pub latest_version: String,
|
|
pub total_download_count: i64,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(has_one = "super::extension_version::Entity")]
|
|
LatestVersion,
|
|
}
|
|
|
|
impl Related<super::extension_version::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::LatestVersion.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|