(queryid string, backendidx int, progress *sourcebackendpb.ProgressUpdate)
| 760 | // Skip this result if it’s not in the newest version of the package. |
| 761 | if packageVersions[name].String() != pkg[underscore+1:] { |
| 762 | continue |
| 763 | } |
| 764 | pkgresults := bypkg[name] |
| 765 | if len(pkgresults) >= resultsPerPackage { |
| 766 | continue |
| 767 | } |
| 768 | pkgresults = append(pkgresults, pointer) |
| 769 | bypkg[name] = pkgresults |
| 770 | } |
| 771 | log.Printf("[%s] by-pkg sorting done (%v).\n", queryid, time.Since(byPkgSortingStarted)) |
| 772 | |
| 773 | stateMu.Lock() |
| 774 | s, ok = state[queryid] |
| 775 | if !ok { |
| 776 | stateMu.Unlock() |
| 777 | return fmt.Errorf("query no longer exists") |
| 778 | } |
| 779 | s.resultPointers = pointers |
| 780 | s.resultPointersByPkg = bypkg |
| 781 | s.resultPages = pages |
| 782 | state[queryid] = s |
| 783 | stateMu.Unlock() |
| 784 | |
| 785 | sendPaginationUpdate(queryid, s) |
| 786 | return nil |
| 787 | } |
| 788 | |
| 789 | func storeProgress(queryid string, backendidx int, progress *sourcebackendpb.ProgressUpdate) { |
| 790 | stateMu.RLock() |
| 791 | s, ok := state[queryid] |
| 792 | stateMu.RUnlock() |
| 793 | if !ok { |
| 794 | return // query no longer exists |
| 795 | } |
| 796 | s.filesMu.Lock() |
| 797 | s.filesTotal[backendidx] = int(progress.FilesTotal) |
| 798 | s.filesProcessed[backendidx] = int(progress.FilesProcessed) |
| 799 | allSet := true |
| 800 | for i := 0; i < len(common.SourceBackendStubs); i++ { |
| 801 | if s.filesTotal[i] == -1 { |
| 802 | log.Printf("total number for backend %d missing\n", i) |
| 803 | allSet = false |
| 804 | break |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | filesProcessed := 0 |
| 809 | for _, processed := range s.filesProcessed { |
| 810 | filesProcessed += processed |
| 811 | } |
| 812 | filesTotal := 0 |
| 813 | for _, total := range s.filesTotal { |
| 814 | filesTotal += total |
no test coverage detected