Refactor: Extract the quirks_path package as a standalone module and replace eyre with color-eyre.

This commit is contained in:
2025-01-05 23:51:31 +08:00
parent 40cbf86f0f
commit 2ed2b864b2
28 changed files with 231 additions and 2117 deletions

View File

@@ -112,9 +112,9 @@ impl Model {
mikan_bangumi_id: String,
mikan_fansub_id: String,
f: F,
) -> eyre::Result<Model>
) -> color_eyre::eyre::Result<Model>
where
F: AsyncFnOnce(&mut ActiveModel) -> eyre::Result<()>,
F: AsyncFnOnce(&mut ActiveModel) -> color_eyre::eyre::Result<()>,
{
let db = &ctx.db;
if let Some(existed) = Entity::find()

View File

@@ -137,7 +137,7 @@ impl Model {
ctx: &AppContext,
subscription_id: i32,
creations: impl IntoIterator<Item = MikanEpsiodeCreation>,
) -> eyre::Result<()> {
) -> color_eyre::eyre::Result<()> {
let db = &ctx.db;
let new_episode_active_modes = creations
.into_iter()
@@ -187,7 +187,7 @@ impl ActiveModel {
pub fn from_mikan_episode_meta(
ctx: &AppContext,
creation: MikanEpsiodeCreation,
) -> eyre::Result<Self> {
) -> color_eyre::eyre::Result<Self> {
let item = creation.episode;
let bgm = creation.bangumi;
let raw_meta = parse_episode_meta_from_raw_name(&item.episode_title)

View File

@@ -128,7 +128,10 @@ impl Model {
subscriber.ok_or_else(|| ModelError::EntityNotFound)
}
pub async fn find_pid_by_id_with_cache(ctx: &AppContext, id: i32) -> eyre::Result<String> {
pub async fn find_pid_by_id_with_cache(
ctx: &AppContext,
id: i32,
) -> color_eyre::eyre::Result<String> {
let db = &ctx.db;
let cache = &ctx.cache;
let pid = cache

View File

@@ -182,7 +182,7 @@ impl Model {
ctx: &AppContext,
create_dto: SubscriptionCreateDto,
subscriber_id: i32,
) -> eyre::Result<Self> {
) -> color_eyre::eyre::Result<Self> {
let db = &ctx.db;
let subscription = ActiveModel::from_create_dto(create_dto, subscriber_id);
@@ -193,7 +193,7 @@ impl Model {
ctx: &AppContext,
ids: impl Iterator<Item = i32>,
enabled: bool,
) -> eyre::Result<()> {
) -> color_eyre::eyre::Result<()> {
let db = &ctx.db;
Entity::update_many()
.col_expr(Column::Enabled, Expr::value(enabled))
@@ -206,7 +206,7 @@ impl Model {
pub async fn delete_with_ids(
ctx: &AppContext,
ids: impl Iterator<Item = i32>,
) -> eyre::Result<()> {
) -> color_eyre::eyre::Result<()> {
let db = &ctx.db;
Entity::delete_many()
.filter(Column::Id.is_in(ids))
@@ -215,7 +215,7 @@ impl Model {
Ok(())
}
pub async fn pull_subscription(&self, ctx: &AppContext) -> eyre::Result<()> {
pub async fn pull_subscription(&self, ctx: &AppContext) -> color_eyre::eyre::Result<()> {
match &self.category {
SubscriptionCategory::Mikan => {
let mikan_client = ctx.get_mikan_client();
@@ -288,7 +288,7 @@ impl Model {
self.id,
mikan_bangumi_id.to_string(),
mikan_fansub_id.to_string(),
async |am| -> eyre::Result<()> {
async |am| -> color_eyre::eyre::Result<()> {
let bgm_meta = parse_mikan_bangumi_meta_from_mikan_homepage(
Some(mikan_client),
bgm_homepage.clone(),