Skip to content

Commit

Permalink
updating update cmd to change aeon links to hdl link
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnyu committed Mar 9, 2022
1 parent 755ee92 commit 7e7ed44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/spf13/cobra"
"log"
"os"
"sort"
"time"
)

Expand Down Expand Up @@ -71,7 +72,7 @@ func GenerateRoleReport(roles map[string]int) {
}

func HasRole(roles map[string]int, role string) bool {
for k, _ := range roles {
for k := range roles {
if k == role {
return true
}
Expand All @@ -94,9 +95,8 @@ func GetRoles(chunk []ObjectID, resultsChannel chan map[string]int, worker int,
if len(fileVersions) > 0 {
for _, fileVersion := range fileVersions {
role := fileVersion.UseStatement
if role == "service" {
writer.WriteString(fmt.Sprintf("%s\t%s\n", do.URI, fileVersion.FileURI))
writer.Flush()
if role == "" {
role = "undefined"
}
if HasRole(results, role) == true {
results[role] = results[role] + 1
Expand All @@ -110,7 +110,12 @@ func GetRoles(chunk []ObjectID, resultsChannel chan map[string]int, worker int,
}

func PrintRoleMap(roles map[string]int) {
for k, v := range roles {
fmt.Printf("%s\t%d\n", k, v)
roleKeys := []string{}
for k := range roles {
roleKeys = append(roleKeys, k)
}
sort.Strings(roleKeys)
for _, k := range roleKeys {
fmt.Printf("%s\t%d\n", k, roles[k])
}
}
4 changes: 2 additions & 2 deletions cmd/update-roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ var (
var updateCmd = &cobra.Command{
Use: "update-roles",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("UPDATE ROLES")
setClient()
updateRoles()
},
}

func updateRoles() {
fmt.Println("Updating Roles")
GetDOIDs()
doChunks := getChunks(dos)
resultChannel := make(chan []Result)
Expand Down Expand Up @@ -98,12 +96,14 @@ func updateFileVersionRoles(fvs []aspace.FileVersion) []aspace.FileVersion {
for _, fv := range fvs {
if fv.UseStatement == "electronic-records-service" {
fv.UseStatement = "electronic-records-reading-room"
fv.FileURI = "https://hdl.handle.net/2333.1/material-request-placeholder"
newFvs = append(newFvs, fv)
continue
}
if fv.UseStatement == "" || fv.UseStatement == "service" {
if aeonMatcher.MatchString(fv.FileURI) == true {
fv.UseStatement = "electronic-records-reading-room"
fv.FileURI = "https://hdl.handle.net/2333.1/material-request-placeholder"
newFvs = append(newFvs, fv)
continue
}
Expand Down

0 comments on commit 7e7ed44

Please sign in to comment.