chg: [tags] searech messages tags by daterange

dev
terrtia 2023-12-09 16:50:43 +01:00
parent f6db9fe888
commit 943a873124
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
3 changed files with 15 additions and 6 deletions

View File

@ -64,7 +64,7 @@ unsafe_tags = build_unsafe_tags()
# get set_keys: intersection
def get_obj_keys_by_tags(tags, obj_type, subtype='', date=None):
l_set_keys = []
if obj_type == 'item':
if obj_type == 'item' or obj_type == 'message':
for tag in tags:
l_set_keys.append(f'{obj_type}:{subtype}:{tag}:{date}')
else:
@ -657,6 +657,15 @@ def add_object_tag(tag, obj_type, obj_id, subtype=''):
domain = item_basic.get_item_domain(obj_id)
add_object_tag(tag, "domain", domain)
update_tag_metadata(tag, date)
# MESSAGE
elif obj_type == 'message':
timestamp = obj_id.split('/')[1]
date = datetime.datetime.fromtimestamp(float(timestamp)).strftime('%Y%m%d')
r_tags.sadd(f'{obj_type}:{subtype}:{tag}:{date}', obj_id)
# TODO ADD CHAT TAGS ????
update_tag_metadata(tag, date)
else:
r_tags.sadd(f'{obj_type}:{subtype}:{tag}', obj_id)
@ -729,7 +738,7 @@ def delete_object_tags(obj_type, subtype, obj_id):
def get_obj_by_tags(obj_type, l_tags, date_from=None, date_to=None, nb_obj=50, page=1):
# with daterange
l_tagged_obj = []
if obj_type=='item':
if obj_type=='item' or obj_type=='message':
#sanityze date
date_range = sanitise_tags_date_range(l_tags, date_from=date_from, date_to=date_to)
l_dates = Date.substract_date(date_range['date_from'], date_range['date_to'])

View File

@ -4,7 +4,7 @@
</div>
<div class="card-body">
{%if object_type=='item'%}
{%if object_type=='item' or object_type=='message'%}
<div class="row mb-3">
<div class="col-md-6">
<div class="input-group" id="date-range-from">
@ -56,7 +56,7 @@
function searchTags() {
var data = ltags.getValue();
var parameter = "?ltags=" + data + "&object_type={{ object_type }}{%if page%}&page={{ page }}{%endif%}";
{%if object_type=='item'%}
{%if object_type=='item' or object_type=='message'%}
var date_from = $('#date-range-from-input').val();
var date_to =$('#date-range-to-input').val();
parameter = parameter + "&date_from=" + date_from + "&date_to=" + date_to;
@ -68,7 +68,7 @@
}
{%if object_type=='item'%}
{%if object_type=='item' or object_type=='message'%}
$('#date-range-from').dateRangePicker({
separator : ' to ',
getValue: function(){

View File

@ -201,7 +201,7 @@
{% with page=dict_tagged['page'], nb_page_max=dict_tagged['nb_pages'], nb_first_elem=dict_tagged['nb_first_elem'], nb_last_elem=dict_tagged['nb_last_elem'], nb_all_elem=dict_tagged['nb_all_elem'] %}
{% set object_name= dict_tagged['object_name'] %}
{% set target_url=url_for('tags_ui.get_obj_by_tags') + "?object_type=" + dict_tagged['object_type'] + "&ltags=" + dict_tagged['current_tags_str'] %}
{%if dict_tagged["object_type"]=="item"%}
{%if dict_tagged["object_type"]=="item" or dict_tagged["object_type"]=="message"%}
{% set target_url= target_url + "&date_from=" + dict_tagged['date']['date_from'] + "&date_to=" + dict_tagged['date']['date_to'] %}
{%endif%}
{% include 'pagination.html' %}