diff --git a/audit/dodec/src/PerformAggregation.go b/audit/dodec/src/PerformAggregation.go index 46eaf16..ec01545 100644 --- a/audit/dodec/src/PerformAggregation.go +++ b/audit/dodec/src/PerformAggregation.go @@ -38,7 +38,7 @@ func PerformAggregation(db *mongo.Database, ctx context.Context) { } //substringToFindInCodeExamples := "defaultauthdb" //substringToFindInPageURL := "code-examples" - monthForReporting := time.November + monthForReporting := time.January for _, collectionName := range collectionNames { //simpleMap = aggregations.GetCategoryCounts(db, collectionName, simpleMap, ctx) diff --git a/audit/dodec/src/aggregations/FindUsageExamplesForMonth.go b/audit/dodec/src/aggregations/FindUsageExamplesForMonth.go index 1745dcd..655c4db 100644 --- a/audit/dodec/src/aggregations/FindUsageExamplesForMonth.go +++ b/audit/dodec/src/aggregations/FindUsageExamplesForMonth.go @@ -17,7 +17,7 @@ import ( // track the product and sub-product in the types.NewAppliedUsageExampleCounterByProductSubProduct func FindUsageExamplesForMonth(db *mongo.Database, collectionName string, productSubProductCounter types.NewAppliedUsageExampleCounterByProductSubProduct, monthForReporting time.Month, ctx context.Context) types.NewAppliedUsageExampleCounterByProductSubProduct { // Target a specific month (example for November 2025): - targetYear := 2025 + targetYear := 2026 monthStart := time.Date(targetYear, monthForReporting, 1, 0, 0, 0, 0, time.UTC) monthEnd := monthStart.AddDate(0, 1, 0) // First day of next month // Define the aggregation pipeline diff --git a/audit/gdcd/db/BackUpDB.go b/audit/gdcd/db/BackUpDB.go index bf554e4..86ed974 100644 --- a/audit/gdcd/db/BackUpDB.go +++ b/audit/gdcd/db/BackUpDB.go @@ -120,8 +120,10 @@ func getBackupDbNames(client *mongo.Client, ctx context.Context) []string { // Parse the dates from the backup database names to find the oldest backup database. func findOldestBackup(backupNames []string) string { - // Define a reference year (we need a year to work with Go's time package) - const year = 2025 // Arbitrary year for comparison purposes + // Get the current date to determine the year for each backup + now := time.Now() + currentMonth := now.Month() + currentYear := now.Year() // Variables to track the oldest date and its corresponding string var oldestDate time.Time @@ -151,6 +153,13 @@ func findOldestBackup(backupNames []string) string { continue } + // Determine the year for this backup + // If the backup month is after the current month, it must be from the previous year + year := currentYear + if month > currentMonth { + year = currentYear - 1 + } + // Create a time.Time object for the given month and day date := time.Date(year, month, day, 0, 0, 0, 0, time.UTC) diff --git a/audit/gdcd/scripts/parse-log.go b/audit/gdcd/scripts/parse-log.go index ef51024..40d578b 100644 --- a/audit/gdcd/scripts/parse-log.go +++ b/audit/gdcd/scripts/parse-log.go @@ -56,10 +56,12 @@ func main() { codeExampleRemovedRegex := regexp.MustCompile(`Code example removed: Page ID: (.+), (\d+) code examples removed`) codeExampleCreatedRegex := regexp.MustCompile(`Code example created: Page ID: (.+), (\d+) new code examples added`) appliedUsageRegex := regexp.MustCompile(`Applied usage example added: Page ID: (.+), (\d+) new applied usage examples added`) + claimedAppliedUsageRegex := regexp.MustCompile(`New applied usage examples for (.+): (\d+)`) removedPages := make(map[string]PageEvent) createdPages := make(map[string]PageEvent) appliedUsageMap := make(map[string]AppliedUsageExample) + claimedAppliedUsageByProject := make(map[string]int) currentProject := "" @@ -133,6 +135,13 @@ func main() { Count: count, } } + + // Parse claimed applied usage examples per project + if matches := claimedAppliedUsageRegex.FindStringSubmatch(line); matches != nil { + project := matches[1] + count, _ := strconv.Atoi(matches[2]) + claimedAppliedUsageByProject[project] = count + } } if err := scanner.Err(); err != nil { @@ -185,7 +194,7 @@ func main() { } // Print results - printResults(movedPages, trulyCreatedPages, trulyRemovedPages, appliedUsageMap) + printResults(movedPages, trulyCreatedPages, trulyRemovedPages, appliedUsageMap, claimedAppliedUsageByProject) } // isPageMoved checks if a removed page and created page represent the same page that was moved @@ -213,7 +222,7 @@ func isPageMoved(removedID, createdID string, removedCodeExamples, createdCodeEx return false } -func printResults(movedPages []MovedPage, trulyCreatedPages []PageEvent, trulyRemovedPages []PageEvent, appliedUsageMap map[string]AppliedUsageExample) { +func printResults(movedPages []MovedPage, trulyCreatedPages []PageEvent, trulyRemovedPages []PageEvent, appliedUsageMap map[string]AppliedUsageExample, claimedAppliedUsageByProject map[string]int) { fmt.Println("=== MOVED PAGES ===") if len(movedPages) == 0 { fmt.Println("No moved pages found.") @@ -277,4 +286,17 @@ func printResults(movedPages []MovedPage, trulyCreatedPages []PageEvent, trulyRe } fmt.Printf("\nTotal new applied usage examples: %d\n", totalNewAppliedUsage) } + + // Print claimed applied usage examples per project from the logs + fmt.Println("\n=== CLAIMED APPLIED USAGE EXAMPLES PER PROJECT ===") + if len(claimedAppliedUsageByProject) == 0 { + fmt.Println("No claimed applied usage examples found in logs.") + } else { + totalClaimed := 0 + for project, count := range claimedAppliedUsageByProject { + fmt.Printf("CLAIMED [%s]: %d applied usage examples\n", project, count) + totalClaimed += count + } + fmt.Printf("\nTotal claimed applied usage examples: %d\n", totalClaimed) + } }