-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add transaction message filter in GraphQL (#20)
* chore: Separate Graphql schemas * chore: mod tidy * feat: Implements transaction message encoding and message filter * chore: Separate Graphql schemas * feat: Implements transaction message encoding and message filter * fix: Fix lints * fix: Remove filter data model * fix: Remove utils * feat: Change filter logic * fix: Fix lints * chore: Add graphql comments for docs * refactor: Change a graph structure * chore: Add descriptions for docs * feat: Create Filter Functions * feat: Add a token amount filter * feat: Improve transaction performance and handle exception cases * chore: Add descriptions for docs * fix: Fix lints * chore: Add descriptions for docs * fix: Added descriptions to filter functions and made minor fixes * fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> * fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> * fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> * fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> * feat: Update generated models --------- Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
- Loading branch information
Showing
19 changed files
with
5,331 additions
and
1,172 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
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
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)) | ||
} |
Oops, something went wrong.