Skip to content

Commit

Permalink
feat: Better search prefixes, search scene by URL (xbapps#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
toshski authored Dec 30, 2023
1 parent 8aa127b commit 763264a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion pkg/api/scenes.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,20 @@ func (i SceneResource) searchSceneIndex(req *restful.Request, resp *restful.Resp

db, _ := models.GetDB()
defer db.Close()
var scenes []models.Scene

if strings.HasPrefix(q, "http") {
// if searching for a link, see if it is in the external ref table for scene alternate source
var scene models.Scene
splits := strings.Split(q, "?")
q = splits[0]

// see if the url matches a scrapped scene
scene.GetIfExistURL(q)
if scene.ID != 0 {
scenes = append(scenes, scene)
}
}

idx, err := tasks.NewIndex("scenes")
if err != nil {
Expand All @@ -600,7 +614,6 @@ func (i SceneResource) searchSceneIndex(req *restful.Request, resp *restful.Resp
return
}

var scenes []models.Scene
for _, v := range searchResults.Hits {
var scene models.Scene
err := scene.GetIfExist(v.ID)
Expand Down
6 changes: 3 additions & 3 deletions ui/src/QuickFind.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<b-taglist>
<b-tag class="tag is-info is-small">{{$t('Search Fields')}}</b-tag>
<b-tooltip :label="$t('Optional: select one or more words to target searching to a specific field')" :delay="500" position="is-top">
<b-button @click='searchPrefix("title:")' class="tag is-info is-small is-light">title:</b-button>
<b-button @click='searchPrefix("+title:")' class="tag is-info is-small is-light">title:</b-button>
<b-button @click='searchPrefix("cast:")' class="tag is-info is-small is-light">cast:</b-button>
<b-button @click='searchPrefix("site:")' class="tag is-info is-small is-light">site:</b-button>
<b-button @click='searchPrefix("id:")' class="tag is-info is-small is-light">id:</b-button>
<b-button @click='searchPrefix("+site:")' class="tag is-info is-small is-light">site:</b-button>
<b-button @click='searchPrefix("+id:")' class="tag is-info is-small is-light">id:</b-button>
</b-tooltip>&nbsp;
<b-tooltip :label="$t('Add file duration to search')" :delay="500" position="is-top">
<b-button @click='searchDurationPrefix("duration:")' class="tag is-info is-small is-light">duration:</b-button>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/views/files/SceneMatch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<b-taglist>
<b-tag class="tag is-info is-small">{{$t('Search Fields')}}</b-tag>
<b-tooltip :label="$t('Optional: select one or more words to target searching to a specific field')" :delay="500" position="is-top">
<b-button @click='searchPrefix("title:")' class="tag is-info is-small is-light">title:</b-button>
<b-button @click='searchPrefix("+title:")' class="tag is-info is-small is-light">title:</b-button>
<b-button @click='searchPrefix("cast:")' class="tag is-info is-small is-light">cast:</b-button>
<b-button @click='searchPrefix("site:")' class="tag is-info is-small is-light">site:</b-button>
<b-button @click='searchPrefix("id:")' class="tag is-info is-small is-light">id:</b-button>
<b-button @click='searchPrefix("+site:")' class="tag is-info is-small is-light">site:</b-button>
<b-button @click='searchPrefix("+id:")' class="tag is-info is-small is-light">id:</b-button>
</b-tooltip>&nbsp;
<b-tooltip :label="$t('Add file duration to search')" :delay="500" position="is-top">
<b-button @click='searchDurationPrefix("duration:")' class="tag is-info is-small is-light">duration:</b-button>
Expand Down

0 comments on commit 763264a

Please sign in to comment.