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

feat: Add transaction message filter in GraphQL #20

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
18688cd
chore: Separate Graphql schemas
jinoosss Mar 31, 2024
e687f84
chore: mod tidy
jinoosss Mar 31, 2024
525fd6a
feat: Implements transaction message encoding and message filter
jinoosss Mar 31, 2024
207ddb4
chore: Separate Graphql schemas
jinoosss Mar 31, 2024
469327f
feat: Implements transaction message encoding and message filter
jinoosss Apr 1, 2024
fa5912b
fix: Fix lints
jinoosss Apr 1, 2024
0c00242
fix: Remove filter data model
jinoosss Apr 2, 2024
be287d9
fix: Remove utils
jinoosss Apr 2, 2024
aff5033
feat: Change filter logic
jinoosss Apr 2, 2024
4a4a586
fix: Fix lints
jinoosss Apr 2, 2024
4db34fb
chore: Add graphql comments for docs
jinoosss Apr 2, 2024
b11d85c
refactor: Change a graph structure
jinoosss Apr 3, 2024
0427926
chore: Add descriptions for docs
jinoosss Apr 4, 2024
8749b12
feat: Create Filter Functions
jinoosss Apr 4, 2024
30969d9
feat: Add a token amount filter
jinoosss Apr 4, 2024
e221c7f
feat: Improve transaction performance and handle exception cases
jinoosss Apr 4, 2024
598eda1
chore: Add descriptions for docs
jinoosss Apr 4, 2024
2f85473
fix: Fix lints
jinoosss Apr 4, 2024
1ccd5be
chore: Add descriptions for docs
jinoosss Apr 4, 2024
bb12ca2
fix: Added descriptions to filter functions and made minor fixes
jinoosss Apr 4, 2024
6442a93
Merge branch 'main', remote-tracking branch 'origin' into feature/add…
jinoosss Apr 5, 2024
03647cb
fix: Fix naming conventions
jinoosss Apr 8, 2024
1aec0e3
fix: Fix naming conventions
jinoosss Apr 8, 2024
6c8865f
fix: Fix naming conventions
jinoosss Apr 8, 2024
36796cf
fix: Fix naming conventions
jinoosss Apr 8, 2024
6873726
Merge remote-tracking branch 'origin/main' into feature/add-transacti…
jinoosss Apr 8, 2024
d4437af
feat: Update generated models
jinoosss Apr 8, 2024
c0c3a19
Merge branch 'main' into feature/add-transaction-message-filter
jinoosss Apr 8, 2024
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg=
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8=
Expand Down Expand Up @@ -176,6 +178,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/linxGnu/grocksdb v1.8.5 h1:Okfk5B1h0ikCYdDM7Tc5yJUS8LTwAmMBq5IPWTmOLPs=
Expand Down
8 changes: 6 additions & 2 deletions gqlgen.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphql
schema:
- serve/graph/*.graphql
- serve/graph/schema/*.graphql
- serve/graph/schema/**/*.graphql
ajnavarro marked this conversation as resolved.
Show resolved Hide resolved

# Where should the generated server code go?
exec:
Expand Down Expand Up @@ -85,4 +86,7 @@ models:
- github.com/gnolang/tx-indexer/serve/graph/model.Block
Transaction:
model:
- github.com/gnolang/tx-indexer/serve/graph/model.Transaction
- github.com/gnolang/tx-indexer/serve/graph/model.Transaction
TransactionMessage:
model:
- github.com/gnolang/tx-indexer/serve/graph/model.TransactionMessage
31 changes: 31 additions & 0 deletions serve/graph/block_filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package graph

import (
"time"

"github.com/gnolang/tx-indexer/serve/graph/model"
)

// `FilteredBlockBy` checks for conditions in BlockTime.
// By default, the condition is only checked if the input parameter exists.
func FilteredBlockBy(block *model.Block, filter model.BlockFilter) bool {
if block == nil {
return false
}

return filteredBlockByBlockTime(block, filter.FromTime, filter.ToTime)
}

// `filteredBlockByBlockTime` checks block based on block time.
func filteredBlockByBlockTime(block *model.Block, filterFromTime, filterToTime *time.Time) bool {
fromTime := deref(filterFromTime)
toTime := deref(filterToTime)

if filterToTime == nil {
toTime = time.Now()
}

blockTime := block.Time()

return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTime.IsZero() || blockTime.Before(toTime))
}
Loading
Loading