Skip to content

Commit

Permalink
Merge pull request #63 from xushiwei/q
Browse files Browse the repository at this point in the history
tool: stdpkgprogress
  • Loading branch information
xushiwei authored Aug 7, 2024
2 parents 7ef487a + 3c32b84 commit 96c7d33
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions chore/stdpkgprogress/go_stdpkg_progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"fmt"
"math"
"strconv"
"strings"

"github.com/goplus/hdq/fetcher"
"github.com/goplus/hdq/fetcher/githubisstask"
_ "github.com/goplus/hdq/stream/http/nocache"
)

const importedBy = "Imported By: "

// Usage: stdpkgprogress
func main() {
doc, err := fetcher.FromInput("githubisstask", "goplus/llgo#642")
if err != nil {
panic(err)
}
var done, total float64
ret := doc.(githubisstask.Result)
for _, task := range ret.Tasks {
desc := task.Desc // fmt* (Imported By: 4513111)
if pos := strings.Index(desc, "Imported By: "); pos > 0 {
ntext := strings.TrimSuffix(desc[pos+len(importedBy):], ")")
if n, e := strconv.Atoi(ntext); e == nil {
w := math.Log2(float64(n) + 1)
total += w
if task.Done {
done += w
}
}
}
}
fmt.Printf("Progress: %.2f%%\n", done/total*100)
}

0 comments on commit 96c7d33

Please sign in to comment.