Render total charts with all group data available.
This commit is contained in:
		
							parent
							
								
									d615aa2843
								
							
						
					
					
						commit
						f28a0bf505
					
				|  | @ -29,12 +29,9 @@ impl UserCountChart { | |||
|     group_name: &str, | ||||
|     render_point_circles: bool, | ||||
|     truncate: bool, | ||||
|     output_dir: &str, | ||||
|   ) -> Result<PathBuf> { | ||||
|     let parent = if truncate { | ||||
|       parent.join("charts/user-count") | ||||
|     } else { | ||||
|       parent.join("charts-untruncated/user-count") | ||||
|     }; | ||||
|     let parent = parent.join(format!("{}/user-count", output_dir)); | ||||
|     create_dir_all(&parent).await?; | ||||
| 
 | ||||
|     let (mut datapoints, mut min_count, mut max_count) = (vec![], i64::MAX, 0); | ||||
|  |  | |||
|  | @ -115,9 +115,31 @@ pub async fn run() -> Result<()> { | |||
|             groups: GroupDataModel::get_n_most_recent(&db, 31, &group.name) | ||||
|               .await?, | ||||
|           }; | ||||
|           chart | ||||
|             .render(&output, &group.name, true, true, "charts") | ||||
|             .await?; | ||||
|           chart | ||||
|             .render(&output, &group.name, true, false, "charts-untruncated") | ||||
|             .await?; | ||||
| 
 | ||||
|           chart.render(&output, &group.name, true, true).await?; | ||||
|           chart.render(&output, &group.name, true, false).await?; | ||||
|           { | ||||
|             let total_chart = UserCountChart { | ||||
|               groups: GroupDataModel::get_all(&db, &group.name).await?, | ||||
|             }; | ||||
| 
 | ||||
|             total_chart | ||||
|               .render(&output, &group.name, false, true, "charts-total") | ||||
|               .await?; | ||||
|             total_chart | ||||
|               .render( | ||||
|                 &output, | ||||
|                 &group.name, | ||||
|                 false, | ||||
|                 false, | ||||
|                 "charts-total-untruncated", | ||||
|               ) | ||||
|               .await?; | ||||
|           } | ||||
| 
 | ||||
|           GroupTemplate::new(group.description.clone(), &group.name) | ||||
|             .await | ||||
|  |  | |||
|  | @ -42,6 +42,20 @@ impl GroupDataModel { | |||
|     Ok(group) | ||||
|   } | ||||
| 
 | ||||
|   /// Get all the saved group datas from a given group name.
 | ||||
|   pub async fn get_all( | ||||
|     db: &DatabaseConnection, | ||||
|     name: &str, | ||||
|   ) -> Result<Vec<Self>> { | ||||
|     Ok( | ||||
|       GroupDataEntity::find() | ||||
|         .order_by_asc(GroupDataColumn::SnapshotId) | ||||
|         .filter(GroupDataColumn::Name.eq(name)) | ||||
|         .all(db) | ||||
|         .await?, | ||||
|     ) | ||||
|   } | ||||
| 
 | ||||
|   /// Get the N most recently saved group datas from a given group name.
 | ||||
|   pub async fn get_n_most_recent( | ||||
|     db: &DatabaseConnection, | ||||
|  |  | |||
		Reference in New Issue