Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Provide limit warnings to user when API limits are reached. #69590

Merged
merged 8 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import {

interface ServerReturnedResolverData {
readonly type: 'serverReturnedResolverData';
readonly events: ResolverEvent[];
readonly stats: Map<string, ResolverNodeStats>;
readonly payload: {
readonly events: ResolverEvent[];
readonly stats: Map<string, ResolverNodeStats>;
readonly limitReached: boolean;
};
}

interface ServerFailedToReturnResolverData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ describe('resolver graph layout', () => {
describe('when rendering no nodes', () => {
beforeEach(() => {
const events: ResolverEvent[] = [];
const action: DataAction = { type: 'serverReturnedResolverData', events, stats: new Map() };
const action: DataAction = {
type: 'serverReturnedResolverData',
payload: { events, stats: new Map() },
};
store.dispatch(action);
});
it('the graphableProcesses list should only include nothing', () => {
Expand All @@ -128,7 +131,10 @@ describe('resolver graph layout', () => {
describe('when rendering one node', () => {
beforeEach(() => {
const events = [processA];
const action: DataAction = { type: 'serverReturnedResolverData', events, stats: new Map() };
const action: DataAction = {
type: 'serverReturnedResolverData',
payload: { events, stats: new Map() },
};
store.dispatch(action);
});
it('the graphableProcesses list should only include nothing', () => {
Expand All @@ -142,7 +148,10 @@ describe('resolver graph layout', () => {
describe('when rendering two nodes, one being the parent of the other', () => {
beforeEach(() => {
const events = [processA, processB];
const action: DataAction = { type: 'serverReturnedResolverData', events, stats: new Map() };
const action: DataAction = {
type: 'serverReturnedResolverData',
payload: { events, stats: new Map() },
};
store.dispatch(action);
});
it('the graphableProcesses list should only include nothing', () => {
Expand All @@ -166,7 +175,10 @@ describe('resolver graph layout', () => {
processH,
processI,
];
const action: DataAction = { type: 'serverReturnedResolverData', events, stats: new Map() };
const action: DataAction = {
type: 'serverReturnedResolverData',
payload: { events, stats: new Map() },
};
store.dispatch(action);
});
it("the graphableProcesses list should only include events with 'processCreated' an 'processRan' eventType", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const dataReducer: Reducer<DataState, ResolverAction> = (state = initialS
if (action.type === 'serverReturnedResolverData') {
return {
...state,
results: action.events,
relatedEventsStats: action.stats,
results: action.payload.events,
relatedEventsStats: action.payload.stats,
limitReached: action.payload.limitReached,
isLoading: false,
hasError: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ export const resolverMiddlewareFactory: MiddlewareFactory = (context) => {
}
const nodeStats: Map<string, ResolverNodeStats> = new Map();
nodeStats.set(entityId, stats);
const limitReached = children.nextChild !== null || ancestry.nextAncestor !== null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-buttner does this seem right to you? If either nextChild or nextAncestor isn't null we know we didn't get all the stuff, right? Is there a similar thing for lifecycle?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my bad @bkimmel totally missed this. So the thing to note is that we're only requesting the default amount for the API. I wonder if we should always request the max?

As for lifecycle in the backend we're operating under the assumption that we'll always be able to retrieve all the lifecycle nodes for the entire request. We may have to address fixing that later though but for now there's no nextLifecycle.

const events = [
...lifecycle,
...getLifecycleEventsAndStats(children.childNodes, nodeStats),
...getLifecycleEventsAndStats(ancestry.ancestors, nodeStats),
];
api.dispatch({
type: 'serverReturnedResolverData',
events,
stats: nodeStats,
payload: {
events,
stats: nodeStats,
limitReached,
},
});
} catch (error) {
api.dispatch({
Expand Down