Projet

Général

Profil

0001-misc-use-mtime-of-schema-as-last-update-time-41836.patch

Benjamin Dauvergne, 20 avril 2020 16:12

Télécharger (3,81 ko)

Voir les différences:

Subject: [PATCH] misc: use mtime of schema as last update time (#41836)

 bijoe/schemas.py                     | 3 ++-
 bijoe/templates/bijoe/cube.html      | 1 +
 bijoe/templates/bijoe/homepage.html  | 4 +++-
 bijoe/templates/bijoe/warehouse.html | 1 +
 bijoe/utils.py                       | 7 ++++++-
 5 files changed, 13 insertions(+), 3 deletions(-)
bijoe/schemas.py
415 415

  
416 416

  
417 417
class Warehouse(Base):
418
    __slots__ = ['name', 'slug', 'label', 'pg_dsn', 'search_path', 'cubes', 'path']
418
    __slots__ = ['name', 'slug', 'label', 'pg_dsn', 'search_path', 'cubes', 'path', 'timestamp']
419 419
    __types__ = {
420 420
        'name': str,
421 421
        'slug': str,
......
429 429
    def __init__(self, **kwargs):
430 430
        self.path = None
431 431
        self.slug = None
432
        self.timestamp = None
432 433
        super(Warehouse, self).__init__(**kwargs)
433 434

  
434 435
    def check(self):
bijoe/templates/bijoe/cube.html
71 71
      <a rel="popup" href="{% url "create-visualization" warehouse=warehouse.name cube=cube.name %}?{% firstof view.request.POST.urlencode view.request.GET.urlencode %}"
72 72
         title="{{ visualization.title }}" class="button">{% trans "Save" %}</a>
73 73
    {% endblock %}
74
    <p>{% trans "Last update" %} {{ warehouse.timestamp }}</p>
74 75
  {% else %}
75 76
    <div class="big-msg-info">{% trans "Please choose some measures and groupings." %}</div>
76 77
  {% endif %}
bijoe/templates/bijoe/homepage.html
28 28
    <ul class="objects-list single-links bijoe-warehouses">
29 29
      {% for warehouse in warehouses %}
30 30
         {% url 'warehouse' warehouse=warehouse.name as warehouse_url %}
31
         <li><a href="{{ warehouse_url }}">{{ warehouse.label }}</a></li>
31
         <li>
32
                 <a href="{{ warehouse_url }}">{{ warehouse.label }} ({% trans "last update" %} {{ warehouse.timestamp}})</a>
33
         </li>
32 34
      {% endfor %}
33 35
    </ul>
34 36
  {% endif %}
bijoe/templates/bijoe/warehouse.html
12 12
{% endblock %}
13 13

  
14 14
{% block content %}
15
  <p>{% trans "Last update " %} {{ warehouse.timestamp }}</p>
15 16
  <table class="bijoe-table bijoe-form-table main">
16 17
    <thead>
17 18
      <tr>
bijoe/utils.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import datetime
17 18
import os
18 19
import glob
19 20
import json
......
21 22
from django.conf import settings
22 23
from django.db import connection, transaction
23 24
from django.utils.translation import ugettext as _
25
from django.utils.timezone import utc
26

  
24 27
try:
25 28
    from functools import lru_cache
26 29
except ImportError:
......
41 44

  
42 45
@lru_cache()
43 46
def get_warehouse_by_path_and_mtime(path, mtime):
44
    warehouse = json.load(open(path))
47
    with open(path) as fd:
48
        warehouse = json.load(fd)
45 49
    warehouse['path'] = path
50
    warehouse['timestamp'] = datetime.datetime.fromtimestamp(os.path.getmtime(path), utc)
46 51
    return Warehouse.from_json(warehouse)
47 52

  
48 53

  
49
-