Skip to content

Commit

Permalink
Fixes for flavor types and flavors
Browse files Browse the repository at this point in the history
  • Loading branch information
richmahn committed Dec 8, 2023
1 parent df397ef commit 2f94dfb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 16 deletions.
26 changes: 23 additions & 3 deletions models/user/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,35 @@ func SearchUsers(ctx context.Context, opts *SearchUserOptions) (users []*User, _
}
repoMetadataCond = repoMetadataCond.And(repoSubsCond)
}
if len(opts.RepoFlavorTypes) > 0 {
hasMetadataCond = true
repoFlavorTypesCond := builder.NewCond()
for _, values := range opts.RepoFlavorTypes {
for _, value := range strings.Split(values, ",") {
repoFlavorTypesCond = repoFlavorTypesCond.Or(builder.Eq{"`door43_metadata`.flavor_type": strings.TrimSpace(value)})
}
}
repoMetadataCond = repoMetadataCond.And(repoFlavorTypesCond)
}
if len(opts.RepoFlavors) > 0 {
hasMetadataCond = true
repoFlavorCond := builder.NewCond()
for _, values := range opts.RepoFlavorTypes {
for _, value := range strings.Split(values, ",") {
repoFlavorCond = repoFlavorCond.Or(builder.Eq{"`door43_metadata`.flavor": strings.TrimSpace(value)})
}
}
repoMetadataCond = repoMetadataCond.And(repoFlavorCond)
}
if len(opts.RepoMetadataTypes) > 0 {
hasMetadataCond = true
repoTypesCond := builder.NewCond()
repoMetadataTypesCond := builder.NewCond()
for _, values := range opts.RepoMetadataTypes {
for _, value := range strings.Split(values, ",") {
repoTypesCond = repoTypesCond.Or(builder.Eq{"`door43_metadata`.metadata_type": strings.TrimSpace(value)})
repoMetadataTypesCond = repoMetadataTypesCond.Or(builder.Eq{"`door43_metadata`.metadata_type": strings.TrimSpace(value)})
}
}
repoMetadataCond = repoMetadataCond.And(repoTypesCond)
repoMetadataCond = repoMetadataCond.And(repoMetadataTypesCond)
}
if opts.RepoLanguageIsGL != util.OptionalBoolNone {
hasMetadataCond = true
Expand Down
31 changes: 25 additions & 6 deletions routers/api/v1/org/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,44 @@ func GetAll(ctx *context.APIContext) {
// parameters:
// - name: lang
// in: query
// description: if the org has one or more repos with the given language(s), the org will be in the results. Multiple lang's are ORed.
// description: has repos of the given language. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: is_gl
// in: query
// description: if the org has one or more repos that is a gateway language, the org will be in the results
// description: has repos with a repo that is or is not a gateway language.
// type: boolean
// - name: subject
// in: query
// description: if the org has one or more repos with the given subject(s), the org will be in the results. Multiple subjects are ORed.
// description: has repos with the given subject. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: flavorType
// in: query
// description: org has repos of given flavorType. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: flavor
// in: query
// description: has repos of given flavor. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// enum: [Aligned Bible,Aramaic Grammar,Bible,Greek Grammar,Greek Lexicon,Greek New Testament,Hebrew Grammar,Hebrew Old Testament,Hebrew-Aramaic Lexicon,OBS Study Notes,OBS Study Questions,OBS Translation Notes,OBS Translation Questions,Open Bible Stories,Study Notes,Study Questions,Training Library,Translation Academy,Translation Notes,Translation Questions,Translation Words,TSV Study Notes,TSV Study Questions,TSV Translation Notes,TSV Translation Questions,TSV Translation Words Links,TSV OBS Study Notes,TSV OBS Study Questions,TSV OBS Translation Notes,TSV OBS Translation Questions,TSV OBS Translation Words Links]
// - name: metadataType
// in: query
// description: if the org has one or more repos with the given metadata type(s), the org will be in the results. Multiple metadata types are ORed.
// type: string
// description: has repos of given metadataType. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// enum: [rc,sb,tc,ts]
// - name: page
// in: query
// description: page number of results to return (1-based)
Expand Down Expand Up @@ -235,6 +252,8 @@ func GetAll(ctx *context.APIContext) {
/*** DCS Customizations ***/
RepoLanguages: ctx.FormStrings("lang"),
RepoSubjects: ctx.FormStrings("subject"),
RepoFlavorTypes: ctx.FormStrings("flavorType"),
RepoFlavors: ctx.FormStrings("flavor"),
RepoMetadataTypes: ctx.FormStrings("metadataType"),
/*** END DCS Customizations ***/
})
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func Search(ctx *context.APIContext) {
// type: string
// - name: is_gl
// in: query
// description: if the repo is a gateway language resource, the repo will be in the results
// description: list only those that are (true) or are not (false) a gatetway language
// type: boolean
// - name: subject
// in: query
Expand Down
27 changes: 21 additions & 6 deletions routers/api/v1/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,39 @@ func Search(ctx *context.APIContext) {
// format: int64
// - name: lang
// in: query
// description: if the user has one or more repos with the given language(s), the user will be in the results. Multiple lang's are ORed.
// description: has repos of the given language. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: is_gl
// in: query
// description: if the user has one or more repos that is a gateway language, the user will be in the results
// description: has repos with a repo that is or is not a gateway language.
// type: boolean
// - name: subject
// in: query
// description: if the user has one or more repos with the given subject(s), the user will be in the results. Multiple subjects are ORed.
// description: has repos with the given subject. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: flavorType
// in: query
// description: org has repos of given flavorType. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// - name: flavor
// in: query
// description: has repos of given flavor. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
// type: string
// enum: [Aligned Bible,Aramaic Grammar,Bible,Greek Grammar,Greek Lexicon,Greek New Testament,Hebrew Grammar,Hebrew Old Testament,Hebrew-Aramaic Lexicon,OBS Study Notes,OBS Study Questions,OBS Translation Notes,OBS Translation Questions,Open Bible Stories,Study Notes,Study Questions,Training Library,Translation Academy,Translation Notes,Translation Questions,Translation Words,TSV Study Notes,TSV Study Questions,TSV Translation Notes,TSV Translation Questions,TSV Translation Words Links,TSV OBS Study Notes,TSV OBS Study Questions,TSV OBS Translation Notes,TSV OBS Translation Questions,TSV OBS Translation Words Links]
// - name: metadataType
// in: query
// description: if the user has one or more repos with the given metadata type(s), the user will be in the results. Multiple metadata types are ORed.
// description: has repos of given metadataType. Multiple values are ORed.
// type: array
// collectionFormat: multi
// items:
Expand Down Expand Up @@ -90,7 +103,9 @@ func Search(ctx *context.APIContext) {
// DCS Customizations
RepoLanguages: ctx.FormStrings("lang"),
RepoSubjects: ctx.FormStrings("subject"),
RepoMetadataTypes: ctx.FormStrings("metadata_type"),
RepoMetadataTypes: ctx.FormStrings("metadataType"),
RepoFlavorTypes: ctx.FormStrings("flavorType"),
RepoFlavors: ctx.FormStrings("flavor"),
RepoLanguageIsGL: ctx.FormOptionalBool("is_gl"),
// END DCS Customizations
})
Expand Down

0 comments on commit 2f94dfb

Please sign in to comment.