Skip to content

Commit

Permalink
Added GetFullLineCount() to the Rolodex
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Lobo authored and daveshanley committed Aug 28, 2024
1 parent 49a2921 commit 43144de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index/rolodex.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,23 @@ func (r *Rolodex) RolodexFileSize() int64 {
}
return size
}

// GetFullLineCount returns the total number of lines from all files in the Rolodex
func (r *Rolodex) GetFullLineCount() int64 {
var lineCount int64
for _, v := range r.localFS {
if lfs, ok := v.(RolodexFS); ok {
for _, f := range lfs.GetFiles() {
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
}
}
}
for _, v := range r.remoteFS {
if lfs, ok := v.(RolodexFS); ok {
for _, f := range lfs.GetFiles() {
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
}
}
}
return lineCount
}
3 changes: 3 additions & 0 deletions index/rolodex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,9 @@ func TestRolodex_SimpleTest_OneDoc(t *testing.T) {
assert.Nil(t, rolo.GetRootIndex())
assert.Len(t, rolo.GetIndexes(), 10)

lineCount := rolo.GetFullLineCount()
assert.Equal(t, int64(158), lineCount, "total line count in the rolodex is wrong")

assert.NoError(t, err)
assert.Len(t, rolo.indexes, 10)

Expand Down

0 comments on commit 43144de

Please sign in to comment.