Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #189 from phrase/cleanup-speedup
Browse files Browse the repository at this point in the history
Speed up upload cleanup by increasing per_page keys
  • Loading branch information
theSoenke authored Nov 25, 2019
2 parents 9a3ec4f + 291fb99 commit 034e7fa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.0
1.16.1
2 changes: 1 addition & 1 deletion build/innosetup/phraseapp-client-386.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{DC598D8E-8A9B-4CAD-AFD8-0324FDF4E0F1}
AppName=PhraseApp Client
AppVersion=1.16.0
AppVersion=1.16.1
AppPublisher=PhraseApp GmbH
AppPublisherURL=https://phrase.com/cli
AppSupportURL=https://phrase.com/cli
Expand Down
2 changes: 1 addition & 1 deletion build/innosetup/phraseapp-client.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{DC598D8E-8A9B-4CAD-AFD8-0324FDF4E0F1}
AppName=PhraseApp Client
AppVersion=1.16.0
AppVersion=1.16.1
AppPublisher=PhraseApp GmbH
AppPublisherURL=https://phrase.com/cli
AppSupportURL=https://phrase.com/cli
Expand Down
10 changes: 4 additions & 6 deletions upload_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ func (cmd *UploadCleanupCommand) Run() error {
func UploadCleanup(client *phraseapp.Client, cmd *UploadCleanupCommand) error {
q := "unmentioned_in_upload:" + cmd.ID
params := &phraseapp.KeysListParams{Q: &q}

var err error
page := 1

keys, err := client.KeysList(cmd.Config.DefaultProjectID, page, 25, params)
keys, err := client.KeysList(cmd.Config.DefaultProjectID, page, 100, params)
if err != nil {
return err
}
Expand All @@ -43,8 +41,8 @@ func UploadCleanup(client *phraseapp.Client, cmd *UploadCleanupCommand) error {
}

for len(keys) != 0 {
ids := make([]string, len(keys), len(keys))
names := make([]string, len(keys), len(keys))
ids := make([]string, len(keys))
names := make([]string, len(keys))
for i, key := range keys {
ids[i] = key.ID
names[i] = key.Name
Expand Down Expand Up @@ -79,7 +77,7 @@ func UploadCleanup(client *phraseapp.Client, cmd *UploadCleanupCommand) error {
fmt.Printf("%d key(s) successfully deleted.\n", affected.RecordsAffected)

page++
keys, _ = client.KeysList(cmd.Config.DefaultProjectID, page, 25, params)
keys, _ = client.KeysList(cmd.Config.DefaultProjectID, page, 100, params)
}

return nil
Expand Down

0 comments on commit 034e7fa

Please sign in to comment.