configure fuzzines and snapshot, #build

Changed:
- Added *fuzzy:* secondary keyword for search
- Added take snapshot now button
- Changed snapshot policy to 12pm TZ aware
- Fixed channel page size validator > 0
This commit is contained in:
simon 2022-11-02 12:29:00 +07:00
commit 32fc89f4e7
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
5 changed files with 33 additions and 19 deletions

View File

@ -262,4 +262,4 @@ CORS_ALLOW_HEADERS = list(default_headers) + [
# TA application settings
TA_UPSTREAM = "https://github.com/tubearchivist/tubearchivist"
TA_VERSION = "v0.2.3"
TA_VERSION = "v0.2.4-unstable"

View File

@ -107,8 +107,11 @@ class ElasticSnapshot:
def _build_policy_data(self):
"""build policy dict from config"""
at_12 = datetime.now().replace(hour=12, minute=0, second=0)
hour = at_12.astimezone(ZoneInfo("UTC")).hour
return {
"schedule": "0 30 1 * * ?",
"schedule": f"0 0 {hour} * * ?",
"name": f"<{self.POLICY}_>",
"repository": self.REPO,
"config": {

View File

@ -98,7 +98,9 @@ class ApplicationSettingsForm(forms.Form):
("1", "enable cookie"),
]
subscriptions_channel_size = forms.IntegerField(required=False)
subscriptions_channel_size = forms.IntegerField(
required=False, min_value=1
)
downloads_limit_count = forms.IntegerField(required=False)
downloads_limit_speed = forms.IntegerField(required=False)
downloads_throttledratelimit = forms.IntegerField(required=False)

View File

@ -191,7 +191,7 @@ class SearchParser:
def __init__(self, search_query):
self.query_words = search_query.lower().split()
self.query_map = False
self.query_map = {"term": [], "fuzzy": []}
self.append_to = "term"
def run(self):
@ -214,11 +214,11 @@ class SearchParser:
if ":" in first_word:
index_match, query_string = first_word.split(":")
if index_match in key_word_map:
self.query_map = key_word_map.get(index_match)
self.query_map.update(key_word_map.get(index_match))
self.query_words[0] = query_string
return index_match
self.query_map = key_word_map.get("simple")
self.query_map.update(key_word_map.get("simple"))
print(f"query_map: {self.query_map}")
return "simple"
@ -229,29 +229,24 @@ class SearchParser:
return {
"simple": {
"index": "ta_video,ta_channel,ta_playlist",
"term": [],
},
"video": {
"index": "ta_video",
"term": [],
"channel": [],
"active": [],
},
"channel": {
"index": "ta_channel",
"term": [],
"active": [],
"subscribed": [],
},
"playlist": {
"index": "ta_playlist",
"term": [],
"active": [],
"subscribed": [],
},
"full": {
"index": "ta_subtitle",
"term": [],
"lang": [],
"source": [],
},
@ -329,6 +324,20 @@ class QueryBuilder:
return query
def _get_fuzzy(self):
"""return fuziness valuee"""
fuzzy_value = self.query_map.get("fuzzy", ["auto"])[0]
if fuzzy_value == "no":
return 0
if not fuzzy_value.isdigit():
return "auto"
if int(fuzzy_value) > 2:
return "2"
return fuzzy_value
def _build_simple(self):
"""build simple cross index query"""
must_list = []
@ -339,7 +348,7 @@ class QueryBuilder:
"multi_match": {
"query": term,
"type": "bool_prefix",
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
"operator": "and",
"fields": [
"channel_name._2gram",
@ -368,7 +377,7 @@ class QueryBuilder:
"multi_match": {
"query": term,
"type": "bool_prefix",
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
"operator": "and",
"fields": [
"title._2gram^2",
@ -390,7 +399,7 @@ class QueryBuilder:
"multi_match": {
"query": channel,
"type": "bool_prefix",
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
"operator": "and",
"fields": [
"channel.channel_name._2gram",
@ -413,7 +422,7 @@ class QueryBuilder:
"multi_match": {
"query": term,
"type": "bool_prefix",
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
"operator": "and",
"fields": [
"channel_description",
@ -445,7 +454,7 @@ class QueryBuilder:
"multi_match": {
"query": term,
"type": "bool_prefix",
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
"operator": "and",
"fields": [
"playlist_description",
@ -477,7 +486,7 @@ class QueryBuilder:
"match": {
"subtitle_line": {
"query": term,
"fuzziness": "auto",
"fuzziness": self._get_fuzzy(),
}
}
}

View File

@ -1,10 +1,10 @@
beautifulsoup4==4.11.1
celery==5.2.7
Django==4.1.2
Django==4.1.3
django-auth-ldap==4.1.0
django-cors-headers==3.13.0
djangorestframework==3.14.0
Pillow==9.2.0
Pillow==9.3.0
redis==4.3.4
requests==2.28.1
ryd-client==0.0.6