Skip to content

Commit

Permalink
Pass pointers to WikiSites
Browse files Browse the repository at this point in the history
  • Loading branch information
brawer committed May 25, 2024
1 parent a3f7d52 commit de4a5dc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/qrank-builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Build(client *http.Client, dumps string, numWeeks int, s3 S3) error {
return nil
}

type SiteFileBuilder func(site WikiSite, ctx context.Context, dumps string, s3 S3) error
type SiteFileBuilder func(site *WikiSite, ctx context.Context, dumps string, s3 S3) error

func buildSiteFiles(ctx context.Context, filename string, builder SiteFileBuilder, dumps string, sites *map[string]WikiSite, s3 S3) error {
stored, err := ListStoredFiles(ctx, filename, s3)
Expand All @@ -69,7 +69,7 @@ func buildSiteFiles(ctx context.Context, filename string, builder SiteFileBuilde
if !more {
return nil
}
if err := builder(t, ctx, dumps, s3); err != nil {
if err := builder(&t, ctx, dumps, s3); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/qrank-builder/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestBuildSiteFiles(t *testing.T) {
t.Fatal(err)
}

buildFunc := func(site WikiSite, ctx context.Context, dumps string, s3 S3) error {
buildFunc := func(site *WikiSite, ctx context.Context, dumps string, s3 S3) error {
ymd := site.LastDumped.Format("20060102")
path := fmt.Sprintf("foobar/%s-%s-foobar.zst", site.Key, ymd)
s3.(*FakeS3).data[path] = []byte("fresh-" + ymd[:4])
Expand Down
6 changes: 3 additions & 3 deletions cmd/qrank-builder/pagesignals.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// BuildPageSignals builds the page_signals file for a WikiSite and puts it in S3 storage.
func buildPageSignals(site WikiSite, ctx context.Context, dumps string, s3 S3) error {
func buildPageSignals(site *WikiSite, ctx context.Context, dumps string, s3 S3) error {
ymd := site.LastDumped.Format("20060102")
destPath := fmt.Sprintf("page_signals/%s-%s-page_signals.zst", site.Key, ymd)
logger.Printf("building %s", destPath)
Expand All @@ -50,10 +50,10 @@ func buildPageSignals(site WikiSite, ctx context.Context, dumps string, s3 S3) e
group, groupCtx := errgroup.WithContext(ctx)
group.Go(func() error {
defer close(linesChan)
if err := processPagePropsTable(groupCtx, dumps, &site, linesChan); err != nil {
if err := processPagePropsTable(groupCtx, dumps, site, linesChan); err != nil {
return err
}
if err := processPageTable(groupCtx, dumps, &site, linesChan); err != nil {
if err := processPageTable(groupCtx, dumps, site, linesChan); err != nil {
return err
}
return nil
Expand Down
5 changes: 3 additions & 2 deletions cmd/qrank-builder/pagesignals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func TestBuildPageSignals(t *testing.T) {
if err != nil {
t.Fatal(err)
}
for _, site := range []string{"rmwiki", "wikidatawiki"} {
if err := buildPageSignals((*sites)[site], ctx, dumps, s3); err != nil {
for _, siteKey := range []string{"rmwiki", "wikidatawiki"} {
site := (*sites)[siteKey]
if err := buildPageSignals(&site, ctx, dumps, s3); err != nil {
t.Fatal(err)
}
}
Expand Down

0 comments on commit de4a5dc

Please sign in to comment.