mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add flexibility to daily API usage limit
Summary: Allow exceeding the daily API usage limit for a doc based on additional allocations for the current hour and minute. See the doc comment on getDocApiUsageKeysToIncr for details. This means that up to 5 redis keys may be relevant at a time for a single document. Test Plan: Updated and expanded 'Daily API Limit' tests. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3368
This commit is contained in:
@@ -37,7 +37,7 @@ import {Document} from "app/gen-server/entity/Document";
|
||||
import {Group} from "app/gen-server/entity/Group";
|
||||
import {Login} from "app/gen-server/entity/Login";
|
||||
import {Organization} from "app/gen-server/entity/Organization";
|
||||
import {Product, synchronizeProducts} from "app/gen-server/entity/Product";
|
||||
import {Product, PRODUCTS, synchronizeProducts, testDailyApiLimitFeatures} from "app/gen-server/entity/Product";
|
||||
import {User} from "app/gen-server/entity/User";
|
||||
import {Workspace} from "app/gen-server/entity/Workspace";
|
||||
import {EXAMPLE_WORKSPACE_NAME} from 'app/gen-server/lib/HomeDBManager';
|
||||
@@ -48,6 +48,14 @@ import * as fse from 'fs-extra';
|
||||
|
||||
const ACCESS_GROUPS = ['owners', 'editors', 'viewers', 'guests', 'members'];
|
||||
|
||||
const testProducts = [
|
||||
...PRODUCTS,
|
||||
{
|
||||
name: 'testDailyApiLimit',
|
||||
features: testDailyApiLimitFeatures,
|
||||
},
|
||||
];
|
||||
|
||||
export const exampleOrgs = [
|
||||
{
|
||||
name: 'NASA',
|
||||
@@ -179,11 +187,23 @@ export const exampleOrgs = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'TestDailyApiLimit',
|
||||
domain: 'testdailyapilimit',
|
||||
product: 'testDailyApiLimit',
|
||||
workspaces: [
|
||||
{
|
||||
name: 'TestDailyApiLimitWs',
|
||||
docs: [],
|
||||
}
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const exampleUsers: {[user: string]: {[org: string]: string}} = {
|
||||
Chimpy: {
|
||||
TestDailyApiLimit: 'owners',
|
||||
FreeTeam: 'owners',
|
||||
Chimpyland: 'owners',
|
||||
NASA: 'owners',
|
||||
@@ -527,7 +547,7 @@ export async function createInitialDb(connection?: Connection, migrateAndSeedDat
|
||||
|
||||
// add some test data to the database.
|
||||
export async function addSeedData(connection: Connection) {
|
||||
await synchronizeProducts(connection, true);
|
||||
await synchronizeProducts(connection, true, testProducts);
|
||||
await connection.transaction(async tr => {
|
||||
const seed = new Seed(tr.connection);
|
||||
await seed.run();
|
||||
|
||||
Reference in New Issue
Block a user