Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion audit/dodec/src/PerformAggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion audit/dodec/src/aggregations/FindUsageExamplesForMonth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions audit/gdcd/db/BackUpDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
26 changes: 24 additions & 2 deletions audit/gdcd/scripts/parse-log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ""

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
}
}