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

getdozer / dozer / 6299724219

25 Sep 2023 12:58PM UTC coverage: 77.81% (+0.5%) from 77.275%
6299724219

push

github

chubei
fix: Add `BINDGEN_EXTRA_CLANG_ARGS` to cross compile rocksdb

50223 of 64546 relevant lines covered (77.81%)

148909.49 hits per line

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

92.0
/dozer-api/src/api_helper.rs
1
use crate::auth::Access;
2
use crate::errors::{ApiError, AuthError};
3
use dozer_cache::cache::expression::QueryExpression;
4
use dozer_cache::cache::CacheRecord;
5
use dozer_cache::{AccessFilter, CacheReader};
6
use dozer_types::models::api_security::ApiSecurity;
7

8
pub const API_LATENCY_HISTOGRAM_NAME: &str = "api_latency";
9
pub const API_REQUEST_COUNTER_NAME: &str = "api_requests";
10
pub fn get_record(
1✔
11
    cache_reader: &CacheReader,
1✔
12
    key: &[u8],
1✔
13
    endpoint: &str,
1✔
14
    access: Option<Access>,
1✔
15
) -> Result<CacheRecord, ApiError> {
1✔
16
    let access_filter = get_access_filter(access, endpoint)?;
1✔
17
    let record = cache_reader
1✔
18
        .get(key, &access_filter)
1✔
19
        .map_err(ApiError::NotFound)?;
1✔
20
    Ok(record)
1✔
21
}
1✔
22

23
pub fn get_api_security(current_api_security: Option<ApiSecurity>) -> Option<ApiSecurity> {
144✔
24
    let dozer_master_secret = std::env::var("DOZER_MASTER_SECRET").ok();
144✔
25
    dozer_master_secret
144✔
26
        .map(ApiSecurity::Jwt)
144✔
27
        .or(current_api_security)
144✔
28
}
144✔
29

30
pub fn get_records_count(
16✔
31
    cache_reader: &CacheReader,
16✔
32
    exp: &mut QueryExpression,
16✔
33
    endpoint: &str,
16✔
34
    access: Option<Access>,
16✔
35
) -> Result<usize, ApiError> {
16✔
36
    let access_filter = get_access_filter(access, endpoint)?;
16✔
37
    cache_reader
16✔
38
        .count(exp, access_filter)
16✔
39
        .map_err(ApiError::CountFailed)
16✔
40
}
16✔
41

42
/// Get multiple records
43
pub fn get_records(
31✔
44
    cache_reader: &CacheReader,
31✔
45
    exp: &mut QueryExpression,
31✔
46
    endpoint: &str,
31✔
47
    access: Option<Access>,
31✔
48
) -> Result<Vec<CacheRecord>, ApiError> {
31✔
49
    let access_filter = get_access_filter(access, endpoint)?;
31✔
50
    cache_reader
31✔
51
        .query(exp, access_filter)
31✔
52
        .map_err(ApiError::QueryFailed)
31✔
53
}
31✔
54

55
fn get_access_filter(access: Option<Access>, endpoint: &str) -> Result<AccessFilter, ApiError> {
56
    match access {
3✔
57
        None | Some(Access::All) => Ok(AccessFilter {
48✔
58
            filter: None,
48✔
59
            fields: vec![],
48✔
60
        }),
48✔
61
        Some(Access::Custom(mut access_filters)) => {
×
62
            if let Some(access_filter) = access_filters.remove(endpoint) {
×
63
                Ok(access_filter)
×
64
            } else {
65
                Err(ApiError::ApiAuthError(AuthError::Unauthorized))
×
66
            }
67
        }
68
    }
69
}
48✔
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

© 2026 Coveralls, Inc