@@ -19,6 +19,7 @@ export default class ChartDataService {
1919 * @param endDate - end date as ISO string (e.g., '2025-01-31T23:59:59Z')
2020 * @param groupBy - grouping interval in minutes (1=minute, 60=hour, 1440=day)
2121 * @param timezoneOffset - user's local timezone offset in minutes (default: 0)
22+ * @param metricType - Redis metric type suffix (e.g., 'events-accepted', 'events-rate-limited')
2223 * @returns Array of data points with timestamp and count
2324 * @throws Error if Redis is not connected (caller should fallback to MongoDB)
2425 */
@@ -27,7 +28,8 @@ export default class ChartDataService {
2728 startDate : string ,
2829 endDate : string ,
2930 groupBy : number ,
30- timezoneOffset = 0
31+ timezoneOffset = 0 ,
32+ metricType : string = 'events-accepted'
3133 ) : Promise < { timestamp : number ; count : number } [ ] > {
3234 // Check if Redis is connected
3335 if ( ! this . redisHelper . isConnected ( ) ) {
@@ -37,7 +39,7 @@ export default class ChartDataService {
3739
3840 // Determine granularity and compose key
3941 const granularity = getTimeSeriesSuffix ( groupBy ) ;
40- const key = composeProjectMetricsKey ( granularity , projectId ) ;
42+ const key = composeProjectMetricsKey ( granularity , projectId , metricType ) ;
4143
4244 // Parse ISO date strings to milliseconds
4345 const start = new Date ( startDate ) . getTime ( ) ;
@@ -46,6 +48,7 @@ export default class ChartDataService {
4648
4749 // Fetch data from Redis
4850 let result : TsRangeResult [ ] = [ ] ;
51+
4952 try {
5053 result = await this . redisHelper . tsRange (
5154 key ,
@@ -65,8 +68,10 @@ export default class ChartDataService {
6568
6669 // Transform data from Redis
6770 const dataPoints : { [ ts : number ] : number } = { } ;
71+
6872 for ( const [ tsStr , valStr ] of result ) {
6973 const tsMs = Number ( tsStr ) ;
74+
7075 dataPoints [ tsMs ] = Number ( valStr ) || 0 ;
7176 }
7277
@@ -79,6 +84,7 @@ export default class ChartDataService {
7984
8085 while ( current <= end ) {
8186 const count = dataPoints [ current ] || 0 ;
87+
8288 filled . push ( {
8389 timestamp : Math . floor ( ( current + timezoneOffset * 60 * 1000 ) / 1000 ) ,
8490 count,
0 commit comments