From f87648149f7fa1dfbd73b3365620609b1357ea79 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Mon, 2 Sep 2024 09:25:02 -0400 Subject: [PATCH 1/3] Only show rangeDates if non-default --- src/apps/chifra/pkg/types/types_chunkaddress.go | 4 +++- src/apps/chifra/pkg/types/types_chunkbloom.go | 4 +++- src/apps/chifra/pkg/types/types_chunkindex.go | 4 +++- src/apps/chifra/pkg/types/types_chunkrecord.go | 4 +++- src/apps/chifra/pkg/types/types_chunkstats.go | 4 +++- src/apps/chifra/pkg/types/types_rangedates.go | 4 ++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/apps/chifra/pkg/types/types_chunkaddress.go b/src/apps/chifra/pkg/types/types_chunkaddress.go index 768389fc83..c7f020b06e 100644 --- a/src/apps/chifra/pkg/types/types_chunkaddress.go +++ b/src/apps/chifra/pkg/types/types_chunkaddress.go @@ -52,7 +52,9 @@ func (s *ChunkAddress) Model(chain, format string, verbose bool, extraOpts map[s if verbose { if format == "json" { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + if !s.RangeDates.IsDefault() { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } } else { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate diff --git a/src/apps/chifra/pkg/types/types_chunkbloom.go b/src/apps/chifra/pkg/types/types_chunkbloom.go index 33d7a9f9ef..47c017c14b 100644 --- a/src/apps/chifra/pkg/types/types_chunkbloom.go +++ b/src/apps/chifra/pkg/types/types_chunkbloom.go @@ -67,7 +67,9 @@ func (s *ChunkBloom) Model(chain, format string, verbose bool, extraOpts map[str if verbose { if format == "json" { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + if !s.RangeDates.IsDefault() { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } } else { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate diff --git a/src/apps/chifra/pkg/types/types_chunkindex.go b/src/apps/chifra/pkg/types/types_chunkindex.go index 877efde668..07dcc3b8c7 100644 --- a/src/apps/chifra/pkg/types/types_chunkindex.go +++ b/src/apps/chifra/pkg/types/types_chunkindex.go @@ -62,7 +62,9 @@ func (s *ChunkIndex) Model(chain, format string, verbose bool, extraOpts map[str if verbose { if format == "json" { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + if !s.RangeDates.IsDefault() { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } } else { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate diff --git a/src/apps/chifra/pkg/types/types_chunkrecord.go b/src/apps/chifra/pkg/types/types_chunkrecord.go index e5f7dc4e28..430a0fee3d 100644 --- a/src/apps/chifra/pkg/types/types_chunkrecord.go +++ b/src/apps/chifra/pkg/types/types_chunkrecord.go @@ -55,7 +55,9 @@ func (s *ChunkRecord) Model(chain, format string, verbose bool, extraOpts map[st if verbose { if format == "json" { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + if !s.RangeDates.IsDefault() { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } } else { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate diff --git a/src/apps/chifra/pkg/types/types_chunkstats.go b/src/apps/chifra/pkg/types/types_chunkstats.go index 2f1799c017..5434990da5 100644 --- a/src/apps/chifra/pkg/types/types_chunkstats.go +++ b/src/apps/chifra/pkg/types/types_chunkstats.go @@ -72,7 +72,9 @@ func (s *ChunkStats) Model(chain, format string, verbose bool, extraOpts map[str if verbose { if format == "json" { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + if !s.RangeDates.IsDefault() { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } } else { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate diff --git a/src/apps/chifra/pkg/types/types_rangedates.go b/src/apps/chifra/pkg/types/types_rangedates.go index 4645c35f9d..4023d92de4 100644 --- a/src/apps/chifra/pkg/types/types_rangedates.go +++ b/src/apps/chifra/pkg/types/types_rangedates.go @@ -67,4 +67,8 @@ func (p1 *RangeDates) Cmp(p2 RangeDates) int64 { return p1.FirstTs.Int64() - p2.FirstTs.Int64() } +func (p1 *RangeDates) IsDefault() bool { + return p1.Cmp(RangeDates{}) == 0 +} + // EXISTING_CODE From d677a8fcee5539b1588d49be8aceb99281b10bc8 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 3 Sep 2024 09:36:43 -0400 Subject: [PATCH 2/3] Makes rangeDates option in chunk type --- .github/PULL_REQUEST_TEMPLATE.md | 17 ----------- .github/workflows/pr-target-check.yml | 3 +- sdk | 2 +- .../chifra/pkg/types/types_chunkaddress.go | 2 +- src/apps/chifra/pkg/types/types_chunkbloom.go | 2 +- src/apps/chifra/pkg/types/types_chunkindex.go | 2 +- .../chifra/pkg/types/types_chunkrecord.go | 2 +- src/apps/chifra/pkg/types/types_chunkstats.go | 2 +- .../classDefinitions/fields/chunkaddress.csv | 2 +- .../classDefinitions/fields/chunkbloom.csv | 2 +- .../classDefinitions/fields/chunkindex.csv | 2 +- .../classDefinitions/fields/chunkrecord.csv | 14 +++++----- .../classDefinitions/fields/chunkstats.csv | 28 +++++++++---------- 13 files changed, 32 insertions(+), 48 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index dbe9c904d9..a24ba2181f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,22 +1,5 @@ ## Description -## Type of change -- [ ] Bug fix (non-breaking change which fixes an issue -- include the issue #) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] Other (please specify): - -## Checklist -- [ ] My code follows the style guidelines of this project -- [ ] I have performed a self-review of my own code -- [ ] I have added minimal comments to my code in difficult to understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] My changes generate no new warnings -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes -- [ ] Any dependent changes have been merged and published in downstream modules - ## PR Target Branch - [ ] I am targeting the `develop` branch for non-release changes. - diff --git a/.github/workflows/pr-target-check.yml b/.github/workflows/pr-target-check.yml index c5930d0711..db95c38f0e 100644 --- a/.github/workflows/pr-target-check.yml +++ b/.github/workflows/pr-target-check.yml @@ -9,7 +9,8 @@ jobs: - name: Check if PR is targeting the 'develop' branch run: | if [ "${{ github.event.pull_request.base.ref }}" != "develop" ]; then - echo "::warning file=${{ github.event.pull_request.url }}::PR is not targeting 'develop'. Please change the target branch to 'develop'." + echo "::error file=${{ github.event.pull_request.url }}::PR is not targeting 'develop'. Please change the target branch to 'develop'." + exit 1 else echo "PR is targeting the 'develop' branch. Everything is okay." fi diff --git a/sdk b/sdk index 35c88728ba..6ca939d212 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 35c88728ba2c9cb9b992f8df0666b407bfacecab +Subproject commit 6ca939d212d03d271124be130ca40a32f1b01b81 diff --git a/src/apps/chifra/pkg/types/types_chunkaddress.go b/src/apps/chifra/pkg/types/types_chunkaddress.go index c7f020b06e..5bb54d9f34 100644 --- a/src/apps/chifra/pkg/types/types_chunkaddress.go +++ b/src/apps/chifra/pkg/types/types_chunkaddress.go @@ -22,7 +22,7 @@ type ChunkAddress struct { Count uint64 `json:"count"` Offset uint64 `json:"offset"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates"` + RangeDates RangeDates `json:"rangeDates,omitempty"` // EXISTING_CODE // EXISTING_CODE } diff --git a/src/apps/chifra/pkg/types/types_chunkbloom.go b/src/apps/chifra/pkg/types/types_chunkbloom.go index 47c017c14b..325a4a2b23 100644 --- a/src/apps/chifra/pkg/types/types_chunkbloom.go +++ b/src/apps/chifra/pkg/types/types_chunkbloom.go @@ -26,7 +26,7 @@ type ChunkBloom struct { NBlooms uint64 `json:"nBlooms"` NInserted uint64 `json:"nInserted"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates"` + RangeDates RangeDates `json:"rangeDates,omitempty"` Size uint64 `json:"size"` // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkindex.go b/src/apps/chifra/pkg/types/types_chunkindex.go index 07dcc3b8c7..804844e50c 100644 --- a/src/apps/chifra/pkg/types/types_chunkindex.go +++ b/src/apps/chifra/pkg/types/types_chunkindex.go @@ -23,7 +23,7 @@ type ChunkIndex struct { NAddresses uint64 `json:"nAddresses"` NAppearances uint64 `json:"nAppearances"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates"` + RangeDates RangeDates `json:"rangeDates,omitempty"` Size uint64 `json:"size"` // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkrecord.go b/src/apps/chifra/pkg/types/types_chunkrecord.go index 430a0fee3d..9345c0c7ed 100644 --- a/src/apps/chifra/pkg/types/types_chunkrecord.go +++ b/src/apps/chifra/pkg/types/types_chunkrecord.go @@ -23,7 +23,7 @@ type ChunkRecord struct { IndexHash base.IpfsHash `json:"indexHash"` IndexSize int64 `json:"indexSize"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates"` + RangeDates RangeDates `json:"rangeDates,omitempty"` // EXISTING_CODE // EXISTING_CODE } diff --git a/src/apps/chifra/pkg/types/types_chunkstats.go b/src/apps/chifra/pkg/types/types_chunkstats.go index 5434990da5..85c1ad9ee9 100644 --- a/src/apps/chifra/pkg/types/types_chunkstats.go +++ b/src/apps/chifra/pkg/types/types_chunkstats.go @@ -24,7 +24,7 @@ type ChunkStats struct { NBlocks uint64 `json:"nBlocks"` NBlooms uint64 `json:"nBlooms"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates"` + RangeDates RangeDates `json:"rangeDates,omitempty"` Ratio float64 `json:"ratio"` RecWid uint64 `json:"recWid"` // EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv index fec19794b8..2a26fbad45 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv @@ -3,4 +3,4 @@ address ,address , , , 1 ,the address in this re range ,blkrange , , , 2 ,the block range of the chunk from which this address record was taken offset ,uint64 , , , 3 ,the offset into the appearance table of the first record for this address count ,uint64 , , , 4 ,the number of records in teh appearance table for this address -rangeDates ,RangeDates , , , 5 ,if verbose, the block and timestamp bounds of the chunk +rangeDates ,RangeDates , ,omitempty , 5 ,if verbose, the block and timestamp bounds of the chunk diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv index be953838b2..cb44351cec 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv @@ -6,4 +6,4 @@ nBlooms ,uint64 , , , 4 ,the number of individu nInserted ,uint64 , , , 5 ,the number of addresses inserted into the bloom file size ,uint64 , , , 6 ,the size on disc in bytes of this bloom file byteWidth ,uint64 , , , 7 ,the width of the bloom filter -rangeDates ,RangeDates , , , 8 ,if verbose, the block and timestamp bounds of the chunk +rangeDates ,RangeDates , ,omitempty , 8 ,if verbose, the block and timestamp bounds of the chunk diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv index ce542f8626..3a8b01632f 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv @@ -5,4 +5,4 @@ hash ,hash , , , 3 ,the hash of the spec nAddresses ,uint64 , , , 4 ,the number of addresses in this chunk nAppearances ,uint64 , , , 5 ,the number of appearances in this chunk size ,uint64 , , , 6 ,the size of the chunk in bytes -rangeDates ,RangeDates , , , 7 ,if verbose, the block and timestamp bounds of the chunk +rangeDates ,RangeDates , ,omitempty , 7 ,if verbose, the block and timestamp bounds of the chunk diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv index 3920f6b193..16db2ff218 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv @@ -1,7 +1,7 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk -bloomHash ,ipfshash , , , 2 ,the IPFS hash of the bloom filter at that range -indexHash ,ipfshash , , , 3 ,the IPFS hash of the index chunk at that range -bloomSize ,int64 , ,sorts , 4 ,the size of the bloom filter in bytes -indexSize ,int64 , ,sorts , 5 ,the size of the index portion in bytes -rangeDates ,RangeDates , ,sorts , 6 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk +bloomHash ,ipfshash , , , 2 ,the IPFS hash of the bloom filter at that range +indexHash ,ipfshash , , , 3 ,the IPFS hash of the index chunk at that range +bloomSize ,int64 , ,sorts , 4 ,the size of the bloom filter in bytes +indexSize ,int64 , ,sorts , 5 ,the size of the index portion in bytes +rangeDates ,RangeDates , ,sorts|omitempty , 6 ,if verbose, the block and timestamp bounds of the chunk diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv index 47842bcdcc..097c9186cf 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv @@ -1,14 +1,14 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk -nAddrs ,uint64 , ,sorts , 2 ,the number of addresses in the chunk -nApps ,uint64 , ,sorts , 3 ,the number of appearances in the chunk -nBlocks ,uint64 , ,sorts , 4 ,the number of blocks in the chunk -nBlooms ,uint64 , ,sorts , 5 ,the number of bloom filters in the chunk's bloom -recWid ,uint64 , , , 6 ,the record width of a single bloom filter -bloomSz ,uint64 , ,sorts , 7 ,the size of the bloom filters on disc in bytes -chunkSz ,uint64 , ,sorts , 8 ,the size of the chunks on disc in bytes -addrsPerBlock ,float64 , ,sorts , 9 ,the average number of addresses per block -appsPerBlock ,float64 , ,sorts , 10 ,the average number of appearances per block -appsPerAddr ,float64 , ,sorts , 11 ,the average number of appearances per address -ratio ,float64 , ,sorts , 12 ,the ratio of appearances to addresses -rangeDates ,RangeDates , ,sorts , 13 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk +nAddrs ,uint64 , ,sorts , 2 ,the number of addresses in the chunk +nApps ,uint64 , ,sorts , 3 ,the number of appearances in the chunk +nBlocks ,uint64 , ,sorts , 4 ,the number of blocks in the chunk +nBlooms ,uint64 , ,sorts , 5 ,the number of bloom filters in the chunk's bloom +recWid ,uint64 , , , 6 ,the record width of a single bloom filter +bloomSz ,uint64 , ,sorts , 7 ,the size of the bloom filters on disc in bytes +chunkSz ,uint64 , ,sorts , 8 ,the size of the chunks on disc in bytes +addrsPerBlock ,float64 , ,sorts , 9 ,the average number of addresses per block +appsPerBlock ,float64 , ,sorts , 10 ,the average number of appearances per block +appsPerAddr ,float64 , ,sorts , 11 ,the average number of appearances per address +ratio ,float64 , ,sorts , 12 ,the ratio of appearances to addresses +rangeDates ,RangeDates , ,sorts|omitempty , 13 ,if verbose, the block and timestamp bounds of the chunk From 3a727bbf47a11ead02dd90417b3cbd4cde442a9d Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 3 Sep 2024 20:51:30 -0400 Subject: [PATCH 3/3] Makes rangeDates a pointer --- .../chifra/internal/chunks/handle_address.go | 3 +- .../chifra/internal/chunks/handle_blooms.go | 3 +- .../chifra/internal/chunks/handle_index.go | 3 +- .../internal/chunks/handle_index_belongs.go | 3 +- .../chifra/internal/chunks/handle_manifest.go | 6 ++- src/apps/chifra/internal/chunks/options.go | 3 +- .../chifra/pkg/types/types_chunkaddress.go | 17 ++++---- src/apps/chifra/pkg/types/types_chunkbloom.go | 31 +++++++------- src/apps/chifra/pkg/types/types_chunkindex.go | 29 +++++++------- .../chifra/pkg/types/types_chunkrecord.go | 17 ++++---- .../pkg/types/types_chunkrecord_sort.go | 11 ++++- src/apps/chifra/pkg/types/types_chunkstats.go | 40 +++++++++---------- .../chifra/pkg/types/types_chunkstats_sort.go | 11 ++++- src/apps/chifra/pkg/types/types_rangedates.go | 4 -- .../classDefinitions/fields/chunkaddress.csv | 12 +++--- .../classDefinitions/fields/chunkbloom.csv | 18 ++++----- .../classDefinitions/fields/chunkindex.csv | 16 ++++---- .../classDefinitions/fields/chunkrecord.csv | 14 +++---- .../classDefinitions/fields/chunkstats.csv | 28 ++++++------- src/dev_tools/goMaker/types/types_sorts.go | 11 ++++- 20 files changed, 157 insertions(+), 123 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_address.go b/src/apps/chifra/internal/chunks/handle_address.go index fc78a94139..993ac897c1 100644 --- a/src/apps/chifra/internal/chunks/handle_address.go +++ b/src/apps/chifra/internal/chunks/handle_address.go @@ -81,7 +81,8 @@ func (opts *ChunksOptions) HandleAddresses(rCtx *output.RenderCtx, blockNums []b Offset: uint64(obj.Offset), Count: uint64(obj.Count), } - s.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + s.RangeDates = &rd modelChan <- &s cnt++ diff --git a/src/apps/chifra/internal/chunks/handle_blooms.go b/src/apps/chifra/internal/chunks/handle_blooms.go index e7b049a92a..81adca9b8b 100644 --- a/src/apps/chifra/internal/chunks/handle_blooms.go +++ b/src/apps/chifra/internal/chunks/handle_blooms.go @@ -54,7 +54,8 @@ func (opts *ChunksOptions) HandleBlooms(rCtx *output.RenderCtx, blockNums []base ByteWidth: index.BLOOM_WIDTH_IN_BYTES, NInserted: uint64(nInserted), } - s.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + s.RangeDates = &rd modelChan <- &s return true, nil diff --git a/src/apps/chifra/internal/chunks/handle_index.go b/src/apps/chifra/internal/chunks/handle_index.go index b668647fc0..bb84ea07a0 100644 --- a/src/apps/chifra/internal/chunks/handle_index.go +++ b/src/apps/chifra/internal/chunks/handle_index.go @@ -53,7 +53,8 @@ func (opts *ChunksOptions) HandleIndex(rCtx *output.RenderCtx, blockNums []base. NAppearances: uint64(indexChunk.Header.AppearanceCount), Size: uint64(file.FileSize(fileName)), } - s.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + s.RangeDates = &rd modelChan <- &s return true, nil diff --git a/src/apps/chifra/internal/chunks/handle_index_belongs.go b/src/apps/chifra/internal/chunks/handle_index_belongs.go index 7d51c59caa..c50719c4b1 100644 --- a/src/apps/chifra/internal/chunks/handle_index_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_index_belongs.go @@ -176,7 +176,8 @@ func (opts *ChunksOptions) handleResolvedRecords1(modelChan chan types.Modeler, Offset: uint64(s.AddressRecord.Offset), Range: rng.String(), } - ss.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + ss.RangeDates = &rd modelChan <- &ss cnt++ } diff --git a/src/apps/chifra/internal/chunks/handle_manifest.go b/src/apps/chifra/internal/chunks/handle_manifest.go index 3d5a9704bb..581e55f09c 100644 --- a/src/apps/chifra/internal/chunks/handle_manifest.go +++ b/src/apps/chifra/internal/chunks/handle_manifest.go @@ -42,7 +42,8 @@ func (opts *ChunksOptions) HandleManifest(rCtx *output.RenderCtx, blockNums []ba IndexHash: chunk.IndexHash, IndexSize: chunk.IndexSize, } - s.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + s.RangeDates = &rd modelChan <- &s } } @@ -65,7 +66,8 @@ func (opts *ChunksOptions) HandleManifest(rCtx *output.RenderCtx, blockNums []ba IndexHash: chunk.IndexHash, IndexSize: chunk.IndexSize, } - ch.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + ch.RangeDates = &rd s.Chunks = append(s.Chunks, ch) } modelChan <- &s diff --git a/src/apps/chifra/internal/chunks/options.go b/src/apps/chifra/internal/chunks/options.go index 0619b297c7..6677fcb681 100644 --- a/src/apps/chifra/internal/chunks/options.go +++ b/src/apps/chifra/internal/chunks/options.go @@ -312,7 +312,8 @@ func GetChunkStats(chain, path string) (s types.ChunkStats, err error) { ChunkSz: uint64(file.FileSize(index.ToIndexPath(path))), RecWid: 4 + index.BLOOM_WIDTH_IN_BYTES, } - s.RangeDates = tslib.RangeToBounds(chain, &rng) + rd := tslib.RangeToBounds(chain, &rng) + s.RangeDates = &rd if s.NBlocks > 0 { s.AddrsPerBlock = float64(s.NAddrs) / float64(s.NBlocks) diff --git a/src/apps/chifra/pkg/types/types_chunkaddress.go b/src/apps/chifra/pkg/types/types_chunkaddress.go index 5bb54d9f34..8e87310ecd 100644 --- a/src/apps/chifra/pkg/types/types_chunkaddress.go +++ b/src/apps/chifra/pkg/types/types_chunkaddress.go @@ -22,7 +22,7 @@ type ChunkAddress struct { Count uint64 `json:"count"` Offset uint64 `json:"offset"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates,omitempty"` + RangeDates *RangeDates `json:"rangeDates,omitempty"` // EXISTING_CODE // EXISTING_CODE } @@ -50,17 +50,18 @@ func (s *ChunkAddress) Model(chain, format string, verbose bool, extraOpts map[s "count", } - if verbose { - if format == "json" { - if !s.RangeDates.IsDefault() { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data - } - } else { + if verbose && format == "json" { + if s.RangeDates != nil { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } + } else if verbose { + model["firstTs"], model["firstDate"], model["lastTs"], model["lastDate"] = 0, "", 0, "" + order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) + if s.RangeDates != nil { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate model["lastTs"] = s.RangeDates.LastTs model["lastDate"] = s.RangeDates.LastDate - order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) } } // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkbloom.go b/src/apps/chifra/pkg/types/types_chunkbloom.go index 325a4a2b23..137f31a733 100644 --- a/src/apps/chifra/pkg/types/types_chunkbloom.go +++ b/src/apps/chifra/pkg/types/types_chunkbloom.go @@ -20,14 +20,14 @@ import ( // EXISTING_CODE type ChunkBloom struct { - ByteWidth uint64 `json:"byteWidth"` - Hash base.Hash `json:"hash"` - Magic string `json:"magic"` - NBlooms uint64 `json:"nBlooms"` - NInserted uint64 `json:"nInserted"` - Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates,omitempty"` - Size uint64 `json:"size"` + ByteWidth uint64 `json:"byteWidth"` + Hash base.Hash `json:"hash"` + Magic string `json:"magic"` + NBlooms uint64 `json:"nBlooms"` + NInserted uint64 `json:"nInserted"` + Range string `json:"range"` + RangeDates *RangeDates `json:"rangeDates,omitempty"` + Size uint64 `json:"size"` // EXISTING_CODE // EXISTING_CODE } @@ -65,17 +65,18 @@ func (s *ChunkBloom) Model(chain, format string, verbose bool, extraOpts map[str model["hashValue"] = FormattedTag(verbose, s.Hash) } - if verbose { - if format == "json" { - if !s.RangeDates.IsDefault() { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data - } - } else { + if verbose && format == "json" { + if s.RangeDates != nil { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } + } else if verbose { + model["firstTs"], model["firstDate"], model["lastTs"], model["lastDate"] = 0, "", 0, "" + order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) + if s.RangeDates != nil { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate model["lastTs"] = s.RangeDates.LastTs model["lastDate"] = s.RangeDates.LastDate - order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) } } // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkindex.go b/src/apps/chifra/pkg/types/types_chunkindex.go index 804844e50c..0a67d27fed 100644 --- a/src/apps/chifra/pkg/types/types_chunkindex.go +++ b/src/apps/chifra/pkg/types/types_chunkindex.go @@ -18,13 +18,13 @@ import ( // EXISTING_CODE type ChunkIndex struct { - Hash base.Hash `json:"hash"` - Magic string `json:"magic"` - NAddresses uint64 `json:"nAddresses"` - NAppearances uint64 `json:"nAppearances"` - Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates,omitempty"` - Size uint64 `json:"size"` + Hash base.Hash `json:"hash"` + Magic string `json:"magic"` + NAddresses uint64 `json:"nAddresses"` + NAppearances uint64 `json:"nAppearances"` + Range string `json:"range"` + RangeDates *RangeDates `json:"rangeDates,omitempty"` + Size uint64 `json:"size"` // EXISTING_CODE // EXISTING_CODE } @@ -60,17 +60,18 @@ func (s *ChunkIndex) Model(chain, format string, verbose bool, extraOpts map[str model["hashValue"] = FormattedTag(verbose, s.Hash) } - if verbose { - if format == "json" { - if !s.RangeDates.IsDefault() { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data - } - } else { + if verbose && format == "json" { + if s.RangeDates != nil { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } + } else if verbose { + model["firstTs"], model["firstDate"], model["lastTs"], model["lastDate"] = 0, "", 0, "" + order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) + if s.RangeDates != nil { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate model["lastTs"] = s.RangeDates.LastTs model["lastDate"] = s.RangeDates.LastDate - order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) } } // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkrecord.go b/src/apps/chifra/pkg/types/types_chunkrecord.go index 9345c0c7ed..47dc3d03f8 100644 --- a/src/apps/chifra/pkg/types/types_chunkrecord.go +++ b/src/apps/chifra/pkg/types/types_chunkrecord.go @@ -23,7 +23,7 @@ type ChunkRecord struct { IndexHash base.IpfsHash `json:"indexHash"` IndexSize int64 `json:"indexSize"` Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates,omitempty"` + RangeDates *RangeDates `json:"rangeDates,omitempty"` // EXISTING_CODE // EXISTING_CODE } @@ -53,17 +53,18 @@ func (s *ChunkRecord) Model(chain, format string, verbose bool, extraOpts map[st "indexSize", } - if verbose { - if format == "json" { - if !s.RangeDates.IsDefault() { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data - } - } else { + if verbose && format == "json" { + if s.RangeDates != nil { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } + } else if verbose { + model["firstTs"], model["firstDate"], model["lastTs"], model["lastDate"] = 0, "", 0, "" + order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) + if s.RangeDates != nil { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate model["lastTs"] = s.RangeDates.LastTs model["lastDate"] = s.RangeDates.LastDate - order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) } } // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkrecord_sort.go b/src/apps/chifra/pkg/types/types_chunkrecord_sort.go index a7db93d920..2bb3dcc0c6 100644 --- a/src/apps/chifra/pkg/types/types_chunkrecord_sort.go +++ b/src/apps/chifra/pkg/types/types_chunkrecord_sort.go @@ -46,7 +46,16 @@ func ChunkRecordBy(field ChunkRecordField, order SortOrder) func(p1, p2 ChunkRec } case ChunkRecordRangeDates: // RangeDates return func(p1, p2 ChunkRecord) bool { - cmp := p1.RangeDates.Cmp(p2.RangeDates) + if p1.RangeDates == nil && p2.RangeDates == nil { + return false + } + if p1.RangeDates == nil { + return order == Ascending + } + if p2.RangeDates == nil { + return order != Ascending + } + cmp := p1.RangeDates.Cmp(*p2.RangeDates) if order == Ascending { return cmp == -1 } diff --git a/src/apps/chifra/pkg/types/types_chunkstats.go b/src/apps/chifra/pkg/types/types_chunkstats.go index 85c1ad9ee9..4cf21fd106 100644 --- a/src/apps/chifra/pkg/types/types_chunkstats.go +++ b/src/apps/chifra/pkg/types/types_chunkstats.go @@ -14,19 +14,19 @@ import "encoding/json" // EXISTING_CODE type ChunkStats struct { - AddrsPerBlock float64 `json:"addrsPerBlock"` - AppsPerAddr float64 `json:"appsPerAddr"` - AppsPerBlock float64 `json:"appsPerBlock"` - BloomSz uint64 `json:"bloomSz"` - ChunkSz uint64 `json:"chunkSz"` - NAddrs uint64 `json:"nAddrs"` - NApps uint64 `json:"nApps"` - NBlocks uint64 `json:"nBlocks"` - NBlooms uint64 `json:"nBlooms"` - Range string `json:"range"` - RangeDates RangeDates `json:"rangeDates,omitempty"` - Ratio float64 `json:"ratio"` - RecWid uint64 `json:"recWid"` + AddrsPerBlock float64 `json:"addrsPerBlock"` + AppsPerAddr float64 `json:"appsPerAddr"` + AppsPerBlock float64 `json:"appsPerBlock"` + BloomSz uint64 `json:"bloomSz"` + ChunkSz uint64 `json:"chunkSz"` + NAddrs uint64 `json:"nAddrs"` + NApps uint64 `json:"nApps"` + NBlocks uint64 `json:"nBlocks"` + NBlooms uint64 `json:"nBlooms"` + Range string `json:"range"` + RangeDates *RangeDates `json:"rangeDates,omitempty"` + Ratio float64 `json:"ratio"` + RecWid uint64 `json:"recWid"` // EXISTING_CODE // EXISTING_CODE } @@ -70,17 +70,17 @@ func (s *ChunkStats) Model(chain, format string, verbose bool, extraOpts map[str "ratio", } - if verbose { - if format == "json" { - if !s.RangeDates.IsDefault() { - model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data - } - } else { + if verbose && format == "json" { + if s.RangeDates != nil { + model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data + } + } else if verbose { + order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) + if s.RangeDates != nil { model["firstTs"] = s.RangeDates.FirstTs model["firstDate"] = s.RangeDates.FirstDate model["lastTs"] = s.RangeDates.LastTs model["lastDate"] = s.RangeDates.LastDate - order = append(order, []string{"firstTs", "firstDate", "lastTs", "lastDate"}...) } } // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkstats_sort.go b/src/apps/chifra/pkg/types/types_chunkstats_sort.go index 7e815b6d53..5315b79b50 100644 --- a/src/apps/chifra/pkg/types/types_chunkstats_sort.go +++ b/src/apps/chifra/pkg/types/types_chunkstats_sort.go @@ -103,7 +103,16 @@ func ChunkStatsBy(field ChunkStatsField, order SortOrder) func(p1, p2 ChunkStats } case ChunkStatsRangeDates: // RangeDates return func(p1, p2 ChunkStats) bool { - cmp := p1.RangeDates.Cmp(p2.RangeDates) + if p1.RangeDates == nil && p2.RangeDates == nil { + return false + } + if p1.RangeDates == nil { + return order == Ascending + } + if p2.RangeDates == nil { + return order != Ascending + } + cmp := p1.RangeDates.Cmp(*p2.RangeDates) if order == Ascending { return cmp == -1 } diff --git a/src/apps/chifra/pkg/types/types_rangedates.go b/src/apps/chifra/pkg/types/types_rangedates.go index 4023d92de4..4645c35f9d 100644 --- a/src/apps/chifra/pkg/types/types_rangedates.go +++ b/src/apps/chifra/pkg/types/types_rangedates.go @@ -67,8 +67,4 @@ func (p1 *RangeDates) Cmp(p2 RangeDates) int64 { return p1.FirstTs.Int64() - p2.FirstTs.Int64() } -func (p1 *RangeDates) IsDefault() bool { - return p1.Cmp(RangeDates{}) == 0 -} - // EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv index 2a26fbad45..d6fc8f2b54 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkaddress.csv @@ -1,6 +1,6 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -address ,address , , , 1 ,the address in this record -range ,blkrange , , , 2 ,the block range of the chunk from which this address record was taken -offset ,uint64 , , , 3 ,the offset into the appearance table of the first record for this address -count ,uint64 , , , 4 ,the number of records in teh appearance table for this address -rangeDates ,RangeDates , ,omitempty , 5 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +address ,address , , , 1 ,the address in this record +range ,blkrange , , , 2 ,the block range of the chunk from which this address record was taken +offset ,uint64 , , , 3 ,the offset into the appearance table of the first record for this address +count ,uint64 , , , 4 ,the number of records in teh appearance table for this address +rangeDates ,*RangeDates , ,omitempty , 5 ,if verbose, the block and timestamp bounds of the chunk (may be null) diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv index cb44351cec..bcc710aac0 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkbloom.csv @@ -1,9 +1,9 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , , , 1 ,the block range (inclusive) covered by this chunk -magic ,string , , , 2 ,an internal use only magic number to indicate file format -hash ,hash , , , 3 ,the hash of the specification under which this chunk was generated -nBlooms ,uint64 , , , 4 ,the number of individual bloom filters in this bloom file -nInserted ,uint64 , , , 5 ,the number of addresses inserted into the bloom file -size ,uint64 , , , 6 ,the size on disc in bytes of this bloom file -byteWidth ,uint64 , , , 7 ,the width of the bloom filter -rangeDates ,RangeDates , ,omitempty , 8 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , , , 1 ,the block range (inclusive) covered by this chunk +magic ,string , , , 2 ,an internal use only magic number to indicate file format +hash ,hash , , , 3 ,the hash of the specification under which this chunk was generated +nBlooms ,uint64 , , , 4 ,the number of individual bloom filters in this bloom file +nInserted ,uint64 , , , 5 ,the number of addresses inserted into the bloom file +size ,uint64 , , , 6 ,the size on disc in bytes of this bloom file +byteWidth ,uint64 , , , 7 ,the width of the bloom filter +rangeDates ,*RangeDates , ,omitempty , 8 ,if verbose, the block and timestamp bounds of the chunk (may be null) diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv index 3a8b01632f..06e21e86ea 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkindex.csv @@ -1,8 +1,8 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , , , 1 ,the block range (inclusive) covered by this chunk -magic ,string , , , 2 ,an internal use only magic number to indicate file format -hash ,hash , , , 3 ,the hash of the specification under which this chunk was generated -nAddresses ,uint64 , , , 4 ,the number of addresses in this chunk -nAppearances ,uint64 , , , 5 ,the number of appearances in this chunk -size ,uint64 , , , 6 ,the size of the chunk in bytes -rangeDates ,RangeDates , ,omitempty , 7 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , , , 1 ,the block range (inclusive) covered by this chunk +magic ,string , , , 2 ,an internal use only magic number to indicate file format +hash ,hash , , , 3 ,the hash of the specification under which this chunk was generated +nAddresses ,uint64 , , , 4 ,the number of addresses in this chunk +nAppearances ,uint64 , , , 5 ,the number of appearances in this chunk +size ,uint64 , , , 6 ,the size of the chunk in bytes +rangeDates ,*RangeDates , ,omitempty , 7 ,if verbose, the block and timestamp bounds of the chunk (may be null) diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv index 16db2ff218..2317216b43 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkrecord.csv @@ -1,7 +1,7 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk -bloomHash ,ipfshash , , , 2 ,the IPFS hash of the bloom filter at that range -indexHash ,ipfshash , , , 3 ,the IPFS hash of the index chunk at that range -bloomSize ,int64 , ,sorts , 4 ,the size of the bloom filter in bytes -indexSize ,int64 , ,sorts , 5 ,the size of the index portion in bytes -rangeDates ,RangeDates , ,sorts|omitempty , 6 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk +bloomHash ,ipfshash , , , 2 ,the IPFS hash of the bloom filter at that range +indexHash ,ipfshash , , , 3 ,the IPFS hash of the index chunk at that range +bloomSize ,int64 , ,sorts , 4 ,the size of the bloom filter in bytes +indexSize ,int64 , ,sorts , 5 ,the size of the index portion in bytes +rangeDates ,*RangeDates , ,sorts|omitempty , 6 ,if verbose, the block and timestamp bounds of the chunk (may be null) diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv index 097c9186cf..97ed7f90b8 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/chunkstats.csv @@ -1,14 +1,14 @@ -name ,type ,strDefault ,attributes ,docOrder ,description -range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk -nAddrs ,uint64 , ,sorts , 2 ,the number of addresses in the chunk -nApps ,uint64 , ,sorts , 3 ,the number of appearances in the chunk -nBlocks ,uint64 , ,sorts , 4 ,the number of blocks in the chunk -nBlooms ,uint64 , ,sorts , 5 ,the number of bloom filters in the chunk's bloom -recWid ,uint64 , , , 6 ,the record width of a single bloom filter -bloomSz ,uint64 , ,sorts , 7 ,the size of the bloom filters on disc in bytes -chunkSz ,uint64 , ,sorts , 8 ,the size of the chunks on disc in bytes -addrsPerBlock ,float64 , ,sorts , 9 ,the average number of addresses per block -appsPerBlock ,float64 , ,sorts , 10 ,the average number of appearances per block -appsPerAddr ,float64 , ,sorts , 11 ,the average number of appearances per address -ratio ,float64 , ,sorts , 12 ,the ratio of appearances to addresses -rangeDates ,RangeDates , ,sorts|omitempty , 13 ,if verbose, the block and timestamp bounds of the chunk +name ,type ,strDefault ,attributes ,docOrder ,description +range ,blkrange , ,sorts , 1 ,the block range (inclusive) covered by this chunk +nAddrs ,uint64 , ,sorts , 2 ,the number of addresses in the chunk +nApps ,uint64 , ,sorts , 3 ,the number of appearances in the chunk +nBlocks ,uint64 , ,sorts , 4 ,the number of blocks in the chunk +nBlooms ,uint64 , ,sorts , 5 ,the number of bloom filters in the chunk's bloom +recWid ,uint64 , , , 6 ,the record width of a single bloom filter +bloomSz ,uint64 , ,sorts , 7 ,the size of the bloom filters on disc in bytes +chunkSz ,uint64 , ,sorts , 8 ,the size of the chunks on disc in bytes +addrsPerBlock ,float64 , ,sorts , 9 ,the average number of addresses per block +appsPerBlock ,float64 , ,sorts , 10 ,the average number of appearances per block +appsPerAddr ,float64 , ,sorts , 11 ,the average number of appearances per address +ratio ,float64 , ,sorts , 12 ,the ratio of appearances to addresses +rangeDates ,*RangeDates , ,sorts|omitempty , 13 ,if verbose, the block and timestamp bounds of the chunk (may be null) diff --git a/src/dev_tools/goMaker/types/types_sorts.go b/src/dev_tools/goMaker/types/types_sorts.go index 7fa70a0d47..b007e89c47 100644 --- a/src/dev_tools/goMaker/types/types_sorts.go +++ b/src/dev_tools/goMaker/types/types_sorts.go @@ -122,7 +122,16 @@ func getSortCode(typ string) string { case "RangeDates": return ` case {{.Container}}{{firstUpper .Name}}: // {{.Type}} return func(p1, p2 {{.Container}}) bool { - cmp := p1.{{.GoName}}.Cmp(p2.{{.GoName}}) + if p1.{{.GoName}} == nil && p2.{{.GoName}} == nil { + return false + } + if p1.{{.GoName}} == nil { + return order == Ascending + } + if p2.{{.GoName}} == nil { + return order != Ascending + } + cmp := p1.{{.GoName}}.Cmp(*p2.{{.GoName}}) if order == Ascending { return cmp == -1 }