mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
chg: [tags] searech messages tags by daterange
This commit is contained in:
parent
f6db9fe888
commit
943a873124
3 changed files with 15 additions and 6 deletions
|
@ -64,7 +64,7 @@ unsafe_tags = build_unsafe_tags()
|
||||||
# get set_keys: intersection
|
# get set_keys: intersection
|
||||||
def get_obj_keys_by_tags(tags, obj_type, subtype='', date=None):
|
def get_obj_keys_by_tags(tags, obj_type, subtype='', date=None):
|
||||||
l_set_keys = []
|
l_set_keys = []
|
||||||
if obj_type == 'item':
|
if obj_type == 'item' or obj_type == 'message':
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
l_set_keys.append(f'{obj_type}:{subtype}:{tag}:{date}')
|
l_set_keys.append(f'{obj_type}:{subtype}:{tag}:{date}')
|
||||||
else:
|
else:
|
||||||
|
@ -657,6 +657,15 @@ def add_object_tag(tag, obj_type, obj_id, subtype=''):
|
||||||
domain = item_basic.get_item_domain(obj_id)
|
domain = item_basic.get_item_domain(obj_id)
|
||||||
add_object_tag(tag, "domain", domain)
|
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)
|
update_tag_metadata(tag, date)
|
||||||
else:
|
else:
|
||||||
r_tags.sadd(f'{obj_type}:{subtype}:{tag}', obj_id)
|
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):
|
def get_obj_by_tags(obj_type, l_tags, date_from=None, date_to=None, nb_obj=50, page=1):
|
||||||
# with daterange
|
# with daterange
|
||||||
l_tagged_obj = []
|
l_tagged_obj = []
|
||||||
if obj_type=='item':
|
if obj_type=='item' or obj_type=='message':
|
||||||
#sanityze date
|
#sanityze date
|
||||||
date_range = sanitise_tags_date_range(l_tags, date_from=date_from, date_to=date_to)
|
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'])
|
l_dates = Date.substract_date(date_range['date_from'], date_range['date_to'])
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
{%if object_type=='item'%}
|
{%if object_type=='item' or object_type=='message'%}
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="input-group" id="date-range-from">
|
<div class="input-group" id="date-range-from">
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
function searchTags() {
|
function searchTags() {
|
||||||
var data = ltags.getValue();
|
var data = ltags.getValue();
|
||||||
var parameter = "?ltags=" + data + "&object_type={{ object_type }}{%if page%}&page={{ page }}{%endif%}";
|
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_from = $('#date-range-from-input').val();
|
||||||
var date_to =$('#date-range-to-input').val();
|
var date_to =$('#date-range-to-input').val();
|
||||||
parameter = parameter + "&date_from=" + date_from + "&date_to=" + date_to;
|
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({
|
$('#date-range-from').dateRangePicker({
|
||||||
separator : ' to ',
|
separator : ' to ',
|
||||||
getValue: function(){
|
getValue: function(){
|
||||||
|
|
|
@ -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'] %}
|
{% 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 object_name= dict_tagged['object_name'] %}
|
||||||
{% set target_url=url_for('tags_ui.get_obj_by_tags') + "?object_type=" + dict_tagged['object_type'] + "<ags=" + dict_tagged['current_tags_str'] %}
|
{% set target_url=url_for('tags_ui.get_obj_by_tags') + "?object_type=" + dict_tagged['object_type'] + "<ags=" + 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'] %}
|
{% set target_url= target_url + "&date_from=" + dict_tagged['date']['date_from'] + "&date_to=" + dict_tagged['date']['date_to'] %}
|
||||||
{%endif%}
|
{%endif%}
|
||||||
{% include 'pagination.html' %}
|
{% include 'pagination.html' %}
|
||||||
|
|
Loading…
Reference in a new issue