Improve stats API
This commit is contained in:
		
							parent
							
								
									1cb93a8c10
								
							
						
					
					
						commit
						f9f2ca51ac
					
				
					 1 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
import Meta from '../../../models/meta';
 | 
					import Meta from '../../../models/meta';
 | 
				
			||||||
import define from '../define';
 | 
					import define from '../define';
 | 
				
			||||||
 | 
					import driveChart from '../../../chart/drive';
 | 
				
			||||||
 | 
					import federationChart from '../../../chart/federation';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const meta = {
 | 
					export const meta = {
 | 
				
			||||||
	requireCredential: false,
 | 
						requireCredential: false,
 | 
				
			||||||
| 
						 | 
					@ -15,5 +17,16 @@ export const meta = {
 | 
				
			||||||
export default define(meta, () => new Promise(async (res, rej) => {
 | 
					export default define(meta, () => new Promise(async (res, rej) => {
 | 
				
			||||||
	const meta = await Meta.findOne();
 | 
						const meta = await Meta.findOne();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res(meta ? meta.stats : {});
 | 
						const stats: any = meta ? meta.stats : {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const driveStats = await driveChart.getChart('hour', 1);
 | 
				
			||||||
 | 
						stats.driveUsageLocal = driveStats.local.totalSize[0];
 | 
				
			||||||
 | 
						stats.driveUsageRemote = driveStats.remote.totalSize[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						console.log(driveStats);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const federationStats = await federationChart.getChart('hour', 1);
 | 
				
			||||||
 | 
						stats.instances = federationStats.instance.total[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						res(stats);
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue