File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
valhalla/jawn/src/managers/dataset Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,17 @@ export class HeliconeDatasetManager extends BaseManager {
4747 ) ;
4848 }
4949
50+ private async getTodayRowCount ( ) : Promise < number > {
51+ const result = await dbExecute < { count : number } > (
52+ `SELECT COUNT(*)::int as count
53+ FROM helicone_dataset_row
54+ WHERE organization_id = $1
55+ AND created_at >= CURRENT_DATE` ,
56+ [ this . authParams . organizationId ]
57+ ) ;
58+ return result . data ?. [ 0 ] ?. count ?? 0 ;
59+ }
60+
5061 async getDatasets ( params : {
5162 datasetIds ?: string [ ] ;
5263 } ) : Promise < Result < HeliconeDataset [ ] , string > > {
@@ -205,6 +216,16 @@ export class HeliconeDatasetManager extends BaseManager {
205216 datasetId : string ,
206217 addRequests : string [ ]
207218 ) : Promise < Result < null , string > > {
219+ // Rate limit: 1000 rows per day per organization
220+ const todayCount = await this . getTodayRowCount ( ) ;
221+ if ( todayCount + addRequests . length > 1000 ) {
222+ return err (
223+ `Rate limit exceeded: You can add up to 1000 dataset rows per day. ` +
224+ `Today's usage: ${ todayCount } . Requested: ${ addRequests . length } . ` +
225+ `Limit resets at midnight UTC.`
226+ ) ;
227+ }
228+
208229 try {
209230 // Build the VALUES part of the query dynamically
210231 const values = addRequests
You can’t perform that action at this time.
0 commit comments