Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f48ab9

Browse filesBrowse files
authored
Merge pull request #19 from dacharyc/DOCSP-49543
(DOCSP-49543): GDCD: Fix page count issue bug
2 parents 13a236d + 968dd25 commit 3f48ab9
Copy full SHA for 3f48ab9

File tree

Expand file treeCollapse file tree

3 files changed

+17
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-11
lines changed
Open diff view settings
Collapse file

‎audit/gdcd/CheckDocsForUpdates.go‎

Copy file name to clipboardExpand all lines: audit/gdcd/CheckDocsForUpdates.go
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
// to a log file on the local file system. Then, we perform a batch update with all the changes for this project.
1717
func CheckDocsForUpdates(docsPages []types.PageWrapper, project types.DocsProjectDetails, llm *ollama.LLM, ctx context.Context, report types.ProjectReport) {
1818
incomingPageIdsMatchingExistingPages := make(map[string]bool)
19-
incomingPageCount := len(docsPages)
2019
incomingDeletedPageCount := 0
2120
var newPageIds []string
2221
var newPages []common.DocsPage
@@ -57,8 +56,10 @@ func CheckDocsForUpdates(docsPages []types.PageWrapper, project types.DocsProjec
5756

5857
// Get the existing "summaries" document from the DB, and update it.
5958
var summaryDoc common.CollectionReport
60-
expectedPageCountFromIncomingPages := incomingPageCount - incomingDeletedPageCount
61-
summaryDoc, report = HandleCollectionSummariesDocument(project, report, expectedPageCountFromIncomingPages)
59+
60+
// Adjust the total page count we're getting from Snooty to remove any 'deleted' pages - we don't want to count or track those
61+
report.Counter.TotalCurrentPageCount = report.Counter.TotalCurrentPageCount - incomingDeletedPageCount
62+
summaryDoc, report = HandleCollectionSummariesDocument(project, report)
6263

6364
// Output the project report to the log
6465
LogReportForProject(project.ProjectName, report)
Collapse file

‎audit/gdcd/HandleCollectionSummariesDocument.go‎

Copy file name to clipboardExpand all lines: audit/gdcd/HandleCollectionSummariesDocument.go
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"gdcd/utils"
88
)
99

10-
func HandleCollectionSummariesDocument(project types.DocsProjectDetails, report types.ProjectReport, incomingPageCount int) (common.CollectionReport, types.ProjectReport) {
10+
func HandleCollectionSummariesDocument(project types.DocsProjectDetails, report types.ProjectReport) (common.CollectionReport, types.ProjectReport) {
1111
summaryDoc := db.GetAtlasProjectSummaryData(project.ProjectName)
1212
var latestCollectionInfo common.CollectionInfoView
1313
collectionVersionKey := ""
@@ -49,9 +49,14 @@ func HandleCollectionSummariesDocument(project types.DocsProjectDetails, report
4949
pageCountBeforeUpdating := summaryDoc.Version[project.ActiveBranch].TotalPageCount
5050
updatedSummaryDoc := db.UpdateCollectionVersionDocument(*summaryDoc, project, report)
5151
summaryDoc = &updatedSummaryDoc
52+
53+
// If we take the total pages from the last version of the summary (pageCountBeforeUpdating), add the count of
54+
// new pages, and subtract the count of removed pages, we should have the same number as
55+
// report.Counter.TotalCurrentPageCount. TotalCurrentPageCount is the length of the docs pages array we get from
56+
// Snooty, minus any pages where the deleted flag is true, to reflect the total current count of docs pages in the project.
5257
sumOfExpectedPages := pageCountBeforeUpdating + report.Counter.NewPagesCount - report.Counter.RemovedPagesCount
53-
if sumOfExpectedPages != incomingPageCount {
54-
report = utils.ReportIssues(types.PageCountIssue, report, project.ProjectName, sumOfExpectedPages, incomingPageCount)
58+
if sumOfExpectedPages != report.Counter.TotalCurrentPageCount {
59+
report = utils.ReportIssues(types.PageCountIssue, report, project.ProjectName, sumOfExpectedPages, report.Counter.TotalCurrentPageCount)
5560
}
5661
}
5762

@@ -62,8 +67,8 @@ func HandleCollectionSummariesDocument(project types.DocsProjectDetails, report
6267
if sumOfExpectedCodeNodes != report.Counter.IncomingCodeNodesCount {
6368
report = utils.ReportIssues(types.CodeNodeCountIssue, report, project.ProjectName, sumOfExpectedCodeNodes, report.Counter.IncomingCodeNodesCount)
6469
}
65-
if latestCollectionInfo.TotalPageCount != incomingPageCount {
66-
report = utils.ReportChanges(types.ProjectSummaryPageCountChange, report, project.ProjectName, latestCollectionInfo.TotalPageCount, incomingPageCount)
70+
if latestCollectionInfo.TotalPageCount != report.Counter.TotalCurrentPageCount {
71+
report = utils.ReportChanges(types.ProjectSummaryPageCountChange, report, project.ProjectName, latestCollectionInfo.TotalPageCount, report.Counter.TotalCurrentPageCount)
6772
}
6873
return *summaryDoc, report
6974
}
Collapse file

‎audit/gdcd/compare-code-examples/CompareExistingIncomingCodeExampleSlices.go‎

Copy file name to clipboardExpand all lines: audit/gdcd/compare-code-examples/CompareExistingIncomingCodeExampleSlices.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
)
1212

1313
// CompareExistingIncomingCodeExampleSlices takes []common.CodeNode, which represents the existing code example nodes from
14-
// Atlas, and []types.ASTNode, which represents incoming code examples from the Snooty Data API. It also takes a types.ProjectCounts
15-
// to track various project counts. This function compares the existing code examples with the incoming code examples
14+
// Atlas, and []types.ASTNode, which represents incoming code examples from the Snooty Data API. It also takes a types.ProjectReport
15+
// to track various project changes and counts. This function compares the existing code examples with the incoming code examples
1616
// to find unchanged, updated, new, and removed nodes. It appends these nodes into an updated []common.CodeNode slice,
17-
// which it returns to the call site for making updates to Atlas. It also returns the updated types.ProjectCounts.
17+
// which it returns to the call site for making updates to Atlas. It also returns the updated types.ProjectReport.
1818
func CompareExistingIncomingCodeExampleSlices(existingNodes []common.CodeNode, existingRemovedNodes []common.CodeNode, incomingNodes []types.ASTNode, report types.ProjectReport, pageId string, llm *ollama.LLM, ctx context.Context, isDriversProject bool) ([]common.CodeNode, types.ProjectReport) {
1919
var updatedPageNodes []types.ASTNode
2020
var newPageNodes []types.ASTNode

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.