Skip to content

Commit acd3a40

Browse files
authored
Merge pull request #281 from LalitDeore/marketplace-test
Fix get app query for opensearch
2 parents 11b2236 + adf9348 commit acd3a40

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

db-connector.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7442,11 +7442,6 @@ func GetUserApps(ctx context.Context, userId string) ([]WorkflowApp, error) {
74427442
var buf bytes.Buffer
74437443
query := map[string]interface{}{
74447444
"size": 1000,
7445-
"sort": map[string]interface{}{
7446-
"edited": map[string]interface{}{
7447-
"order": "desc",
7448-
},
7449-
},
74507445
"query": map[string]interface{}{
74517446
"bool": map[string]interface{}{
74527447
"should": []map[string]interface{}{
@@ -7512,6 +7507,12 @@ func GetUserApps(ctx context.Context, userId string) ([]WorkflowApp, error) {
75127507
innerApp := hit.Source
75137508
userApps = append(userApps, innerApp)
75147509
}
7510+
7511+
if len(userApps) > 0 {
7512+
slice.Sort(userApps[:], func(i, j int) bool {
7513+
return userApps[i].Edited > userApps[j].Edited
7514+
})
7515+
}
75157516
} else {
75167517

75177518
cursorStr := ""
@@ -7665,11 +7666,6 @@ func GetAllWorkflowApps(ctx context.Context, maxLen int, depth int) ([]WorkflowA
76657666

76667667
query := map[string]interface{}{
76677668
"size": 1000,
7668-
"sort": map[string]interface{}{
7669-
"edited": map[string]interface{}{
7670-
"order": "desc",
7671-
},
7672-
},
76737669
}
76747670

76757671
if err := json.NewEncoder(&buf).Encode(query); err != nil {
@@ -7764,6 +7760,12 @@ func GetAllWorkflowApps(ctx context.Context, maxLen int, depth int) ([]WorkflowA
77647760
allApps, innerApp = fixAppAppend(allApps, innerApp)
77657761
}
77667762

7763+
if len(allApps) > 0 {
7764+
slice.Sort(allApps[:], func(i, j int) bool {
7765+
return allApps[i].Edited > allApps[j].Edited
7766+
})
7767+
}
7768+
77677769
/*
77687770
deletions := false
77697771
for key, value := range duplicates {

0 commit comments

Comments
 (0)