-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move Context object to new class (#929)
All logic associated with the creation of the context object resides inside the Indexer class, which bloats the file and complicates unit testing. In addition, it prevents access to the context object itself so that these calls can be made through the Indexer class itself. This PR refactors this logic into its own class, allowing access to context methods through Indexer. The object is still recreated each time it is accessed as the object bakes in some state information (block height and log entry array) which need to be updated on subsequent accesses. I've also reorganized the folders so that we have fewer folders under src as it is getting cluttered.
- Loading branch information
Showing
24 changed files
with
1,092 additions
and
1,324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ redis/ | |
node_modules/ | ||
.vscode/ | ||
runner/yarn.lock | ||
**/.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default } from './indexer-config'; | ||
export { ProvisioningConfig, LocalIndexerConfig } from './indexer-config'; |
This file was deleted.
Oops, something went wrong.
158 changes: 158 additions & 0 deletions
158
runner/src/indexer/context-builder/__snapshots__/context-builder.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ContextBuilder unit tests Context object social api can fetch from the near social api 1`] = ` | ||
[ | ||
[ | ||
"https://api.near.social/index", | ||
{ | ||
"body": "{"action":"post","key":"main","options":{"limit":1,"order":"desc"}}", | ||
"headers": { | ||
"Content-Type": "application/json", | ||
}, | ||
"method": "POST", | ||
}, | ||
], | ||
] | ||
`; | ||
|
||
exports[`ContextBuilder unit tests ContextBuilder adds CRUD operations for table 1`] = ` | ||
{ | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
} | ||
`; | ||
|
||
exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 1`] = ` | ||
{ | ||
"Posts": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 2`] = ` | ||
{ | ||
"Comments": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"PostLikes": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"Posts": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 3`] = ` | ||
{ | ||
"CommentsTable": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"Posts": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`ContextBuilder unit tests ContextBuilder can parse various schemas 4`] = ` | ||
{ | ||
"AnotherTable": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"Comments": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"ComposerQuest": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"ContractorQuest": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"CreatorQuest": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"MyTable1": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"PostLikes": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"Posts": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"ThirdTable": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
"YetAnotherTable": { | ||
"delete": [Function], | ||
"insert": [Function], | ||
"select": [Function], | ||
"update": [Function], | ||
"upsert": [Function], | ||
}, | ||
} | ||
`; |
Oops, something went wrong.