Skip to content

Commit

Permalink
cleanup, unused lines
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrrt committed Nov 18, 2023
1 parent 8bb1b67 commit 3e9996e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@graphql-tools/schema": "^10.0.0",
"graphql-yoga": "^5.0.0",
"itty-durable": "^2.1.0",
"jest": "^29.7.0",
"node-fetch": "^3.3.2"
}
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/do/RateLimiter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createDurable } from "itty-durable";

export class RateLimiter extends createDurable({
autoReturn: true,
autoPersist: false,
}) {
facetsMap = new Map<string, number>();
constructor(state, env) {
super(state, env);
}

onLoad(): Promise<void> {
return Promise.resolve();
}

incrementFacetValue(facet: string) {
this.facetsMap.set(facet, (this.facetsMap.get(facet) || 0) + 1);
}

getFacetValue(facet: string) {
return this.facetsMap.get(facet) || 0;
}
}
11 changes: 1 addition & 10 deletions packages/core/src/invalidation/invalidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export const mapPathsToTypes = (
export const findFieldsWithId = (
selectionParent: string,
selectionSet: any,
// result: string[] = [],
paths: string[] = [],
currentPath: string = "",
mutationId: string = "",
Expand All @@ -120,9 +119,6 @@ export const findFieldsWithId = (
selectionSet: { selections: any[] };
name: { value: string };
}) => {
// if (selection.kind === "Field" && selection.name.value === "id") {
// // result.push(selectionParent);
// }
if (selection.selectionSet) {
// check if selectionSet has id field
const hasIdField = selection.selectionSet.selections.find(
Expand Down Expand Up @@ -248,7 +244,6 @@ const extractTypeNamesAndIds = (obj: any, result: IResult = {}) => {
};
if (Array.isArray(result[typeName])) {
if (!!result[typeName]) {
// @ts-ignore
result[typeName].push(item);
}
}
Expand Down Expand Up @@ -374,7 +369,6 @@ export const splitAggregatedTypesWithIds = (
let currentSize = 0;

for (let i = 0; i < data.length; i++) {
// @ts-ignore
for (let j = 0; data[i].ids?.length && j < data[i].ids.length; j++) {
if (currentSize === chunkSize) {
const aggregated: IAgregateTypesWithIds[] = [];
Expand All @@ -391,15 +385,12 @@ export const splitAggregatedTypesWithIds = (
});

result.push(aggregated);

// Reset currentArray and currentSize
// reset currentArray and currentSize
currentArray = [];
currentSize = 0;
}
currentArray.push({
// @ts-ignore
name: data[i].name,
// @ts-ignore
id: data[i].ids[j],
});
currentSize++;
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ export const readStream = async (reader: {
while (true) {
const { done, value } = await reader.read();
if (done) {
// Stream has been read completely
break;
}

// Assuming the stream is a Uint8Array
const chunk = new TextDecoder().decode(value);
streamData += chunk;
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3e9996e

Please sign in to comment.