<commit_before>%import time
%now = time.time()

%rebase("widget", css=['graphs/css/widget_graphs.css'])

%if not elt:
   <span>No element selected!</span>
%else:

   <!-- Reduce the time range of the dashboard graph to last hour
   and specify the source as dashboard !
   -->
   %uris = app.get_graph_uris(elt, now-3600, now, source='dashboard')
   %if len(uris) == 0:
      <span>No graph for this element.</span>
   %else:
      <div id='widget-graphs'>
      </div>
      <script>
         %for g in uris:
            %(img_src, link) = app.get_graph_img_src(g['img_src'], g['link'])
           // Adjust image width / height parameter ... width is sized to container, and height is 1/3
            var img_src = "{{img_src}}".replace("'","\'")
            img_src = img_src.replace(/(width=).*?(&)/,'$1' + ($('.widget-content').width()-5) + '$2');
            img_src = img_src.replace(/(height=).*?(&)/,'$1' + ($('.widget-content').width() / 2) + '$2');
            
            $('#widget-graphs').append('<p class="widget-graph"><a href="{{link}}" target="_blank"><img src="'+img_src+'"></a></p>');<commit_msg>Widget graph uses relative date<commit_after>%import time
%now = time.time()

%rebase("widget", css=['graphs/css/widget_graphs.css'])

%if not elt:
   <span>No element selected!</span>
%else:

   <!-- Reduce the time range of the dashboard graph to last hour
   and specify the source as dashboard !
   -->
   %uris = app.graphs_module.get_graph_uris(elt, duration=4*3600, source='dashboard')
   %if len(uris) == 0:
      <span>No graph for this element.</span>
   %else:
      <div id='widget-graphs'>
      </div>
      <script>
         %for g in uris:
            %(img_src, link) = app.get_graph_img_src(g['img_src'], g['link'])
           // Adjust image width / height parameter ... width is sized to container, and height is 1/3
            var img_src = "{{img_src}}".replace("'","\'")
            img_src = img_src.replace(/(width=).*?(&)/,'$1' + ($('.widget-content').width()-5) + '$2');
            img_src = img_src.replace(/(height=).*?(&)/,'$1' + ($('.widget-content').width() / 2) + '$2');
            
            $('#widget-graphs').append('<p class="widget-graph"><a href="{{link}}" target="_blank"><img src="'+img_src+'"></a></p>');
{'fraction_non_alphanumeric': 0.21629955947136564, 'fraction_numerical': 0.011894273127753305, 'mean_word_length': 2.8754266211604094, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '404954', 'n_tokens_mistral': 782, 'n_tokens_neox': 758, 'n_words': 176}