Show six labeled activity months
This commit is contained in:
@@ -149,6 +149,8 @@ pub struct HeatCell {
|
||||
pub week: u32,
|
||||
pub day: u32,
|
||||
pub level: u32,
|
||||
pub timestamp: i64,
|
||||
pub contributions: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
@@ -585,7 +587,7 @@ fn activity_detail(activity: &models::Activity) -> String {
|
||||
}
|
||||
|
||||
fn heat_cells(data: &[models::UserHeatmapData]) -> (Vec<HeatCell>, i64) {
|
||||
const DAYS: i64 = 52 * 7;
|
||||
const DAYS: i64 = 6 * 31;
|
||||
let latest = data
|
||||
.iter()
|
||||
.filter_map(|entry| entry.timestamp)
|
||||
@@ -613,6 +615,8 @@ fn heat_cells(data: &[models::UserHeatmapData]) -> (Vec<HeatCell>, i64) {
|
||||
} else {
|
||||
((count * 4 + maximum - 1) / maximum).clamp(1, 4) as u32
|
||||
},
|
||||
timestamp: (start + index as i64) * 86_400,
|
||||
contributions: count,
|
||||
})
|
||||
.collect();
|
||||
(cells, contribution_count)
|
||||
@@ -767,8 +771,16 @@ mod tests {
|
||||
},
|
||||
];
|
||||
let (cells, total) = heat_cells(&heatmap);
|
||||
assert_eq!((cells.len(), total), (364, 5));
|
||||
assert_eq!((cells[362].level, cells[363].level), (1, 4));
|
||||
assert_eq!((cells.len(), total), (186, 5));
|
||||
assert_eq!(
|
||||
(
|
||||
cells[184].level,
|
||||
cells[184].timestamp,
|
||||
cells[184].contributions,
|
||||
cells[185].level,
|
||||
),
|
||||
(1, 100 * 86_400, 1, 4)
|
||||
);
|
||||
|
||||
let label = models::Label {
|
||||
name: Some("bug".into()),
|
||||
|
||||
Reference in New Issue
Block a user