• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

doitsu2014 / my-cms / 14187034714

01 Apr 2025 04:12AM UTC coverage: 59.597% (+20.5%) from 39.058%
14187034714

push

github

web-flow
Feature/support multi language (#19)

* Enhance entity structure: add category and post translations, update migration dependencies, and improve README guidelines

* Add support for category translations: update create and modify handlers, requests, and tests

add TODO

* Add category translations support: update create, modify, and read handlers, and adjust request structures

* Refactor category translation requests: remove slug field and update handlers to set category ID for translations

* Add support for post translations: update create and modify requests, handlers, and models

* Update CI configuration and scripts for improved coverage reporting and toolchain management

* Update coverage configuration and scripts for improved reporting and toolchain management

* Update CI and coverage configurations for improved reporting and ignore patterns

* Update CI configuration and coverage scripts for improved reporting and cleanup

* Remove unused coverage step from CI configuration

* Update CI configuration to use fixed lcov report paths for coverage uploads

197 of 396 new or added lines in 19 files covered. (49.75%)

71 existing lines in 11 files now uncovered.

975 of 1636 relevant lines covered (59.6%)

26.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/application_core/src/commands/media/create/create_handler.rs
1
use crate::{
2
    commands::media::{MediaConfig, MediaModel},
3
    common::app_error::AppError,
4
    StringExtension,
5
};
6
use nanoid::nanoid;
7
use std::sync::Arc;
8
use tracing::info;
9

10
pub struct CreateMediaHandler {
11
    pub media_config: Arc<MediaConfig>,
12
}
13

14
pub trait CreateMediaHandlerTrait {
15
    fn create_image_media(
16
        &self,
17
        media_name: String,
18
        media: &[u8],
19
        content_type: String,
20
    ) -> impl std::future::Future<Output = Result<MediaModel, AppError>>;
21
}
22

23
impl CreateMediaHandlerTrait for CreateMediaHandler {
24
    async fn create_image_media(
×
UNCOV
25
        &self,
×
UNCOV
26
        media_name: String,
×
UNCOV
27
        media: &[u8],
×
UNCOV
28
        content_type: String,
×
29
    ) -> Result<MediaModel, AppError> {
×
UNCOV
30
        let bucket = self.media_config.s3_media_storage.spawn_bucket()?;
×
UNCOV
31
        let media_extension = media_name
×
UNCOV
32
            .clone()
×
UNCOV
33
            .split('.')
×
UNCOV
34
            .last()
×
UNCOV
35
            .unwrap_or_default()
×
UNCOV
36
            .to_string();
×
UNCOV
37
        let media_name_with_nano = format!("{} {}", nanoid!(10), media_name.clone()).to_slug();
×
UNCOV
38
        let beautiful_media_name = format!("{}.{}", media_name_with_nano, media_extension);
×
UNCOV
39
        let response = bucket
×
UNCOV
40
            .put_object_with_content_type(
×
UNCOV
41
                beautiful_media_name.clone(),
×
UNCOV
42
                media,
×
UNCOV
43
                content_type.as_str(),
×
UNCOV
44
            )
×
UNCOV
45
            .await
×
UNCOV
46
            .map_err(|e| e.into())?;
×
UNCOV
47
        info!("{:?}", response);
×
UNCOV
48
        Ok(MediaModel {
×
UNCOV
49
            server: self.media_config.media_imgproxy_server.clone(),
×
UNCOV
50
            path: beautiful_media_name.clone(),
×
UNCOV
51
            imgproxy_url: format!(
×
UNCOV
52
                "{}/insecure/rs:fit/plain/s3://bucket-dzsydl/{}",
×
UNCOV
53
                self.media_config.media_imgproxy_server, beautiful_media_name
×
UNCOV
54
            ),
×
UNCOV
55
        })
×
56
    }
×
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc