Public/Get-PSGalleryStats.ps1

function Get-PSGalleryStats {
    [CmdletBinding()]
    param(
        [Parameter(Position = 0)]
        [ArgumentCompleter({
            param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
            $csvPath = Join-Path (Join-Path $HOME '.PSGalleryTracker') 'PSGalleryDownloads.csv'
            if (Test-Path -LiteralPath $csvPath) {
                Import-Csv -LiteralPath $csvPath |
                    Select-Object -ExpandProperty ModuleName -Unique |
                    Where-Object { $_ -like "$wordToComplete*" } |
                    ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
            }
        })]
        [string]$ModuleName,

        [datetime]$After,

        [datetime]$Before
    )

    $csvPath = Join-Path (Get-SnapshotPath) 'PSGalleryDownloads.csv'

    if (-not (Test-Path -LiteralPath $csvPath)) {
        Write-Warning "CSV file not found. Run Update-PSGalleryStats first."
        return
    }

    $rows = Import-Csv -LiteralPath $csvPath

    foreach ($row in $rows) {
        $row.TotalDownloads = [long]$row.TotalDownloads
        $row | Add-Member -NotePropertyName 'DateParsed' -NotePropertyValue ([datetime]$row.Date) -Force
    }

    if ($PSBoundParameters.ContainsKey('ModuleName')) {
        $rows = @($rows | Where-Object { $_.ModuleName -eq $ModuleName })
    }

    if ($PSBoundParameters.ContainsKey('After')) {
        $rows = @($rows | Where-Object { $_.DateParsed -gt $After })
    }

    if ($PSBoundParameters.ContainsKey('Before')) {
        $rows = @($rows | Where-Object { $_.DateParsed -lt $Before })
    }

    $rows | Select-Object Date, ModuleName, LatestVersion, TotalDownloads
}