Skip to content

Commit

Permalink
Handle pagelinks dumps without namespace column
Browse files Browse the repository at this point in the history
  • Loading branch information
brawer committed Jun 14, 2024
1 parent 330be1f commit 5cc8b85
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/qrank-builder/pagelinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,18 @@ func readPageLinks(ctx context.Context, site *WikiSite, property string, dumps s
}

fromPage := row[fromPageCol]
namespace := row[namespaceCol]
title := row[titleCol]

// Depending on the Wikimedia software version and the wiki project,
// the pagelinks dump may not always have a namespace column.
var namespace string
if namespaceCol >= 0 {
namespace = row[namespaceCol]
}

var nsPrefix string
if namespace != "0" {
if ns, found := site.Namespaces[row[namespaceCol]]; found && ns.Localized != "" {
if len(namespace) > 0 && namespace != "0" {
if ns, found := site.Namespaces[namespace]; found && ns.Localized != "" {
nsPrefix = ns.Localized + ":"
}
}
Expand Down

0 comments on commit 5cc8b85

Please sign in to comment.