diff --git a/flatisfy/cmds.py b/flatisfy/cmds.py
index c48e5c8..89af785 100644
--- a/flatisfy/cmds.py
+++ b/flatisfy/cmds.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals
import collections
import logging
+import os
import flatisfy.filters
from flatisfy import database
@@ -203,6 +204,14 @@ def import_and_filter(config, load_from_db=False):
if config["send_email"]:
email.send_notification(config, new_flats)
+ # Touch a file to indicate last update timestamp
+ ts_file = os.path.join(
+ config["data_directory"],
+ "timestamp"
+ )
+ with open(ts_file, 'w'):
+ os.utime(ts_file, None)
+
LOGGER.info("Done!")
diff --git a/flatisfy/web/app.py b/flatisfy/web/app.py
index 94d7d69..a10e376 100644
--- a/flatisfy/web/app.py
+++ b/flatisfy/web/app.py
@@ -107,6 +107,8 @@ def get_app(config):
app.route("/api/v1/opendata/postal_codes", "GET",
api_routes.opendata_postal_codes_v1)
+ app.route("/api/v1/metadata", ["GET", "OPTIONS"], api_routes.metadata_v1)
+
# Index
app.route("/", "GET", lambda: _serve_static_file("index.html"))
diff --git a/flatisfy/web/js_src/api/index.js b/flatisfy/web/js_src/api/index.js
index 59be30e..fbcb524 100644
--- a/flatisfy/web/js_src/api/index.js
+++ b/flatisfy/web/js_src/api/index.js
@@ -161,3 +161,10 @@ export const doSearch = function (query, callback) {
console.error('Unable to perform search: ' + ex)
})
}
+
+export const getMetadata = function (callback) {
+ fetch('/api/v1/metadata', { credentials: 'same-origin' })
+ .then(response => response.json())
+ .then(json => callback(json.data))
+ .catch(ex => console.error('Unable to fetch application metadata: ' + ex))
+}
diff --git a/flatisfy/web/js_src/components/flatstable.vue b/flatisfy/web/js_src/components/flatstable.vue
index 6d4d632..c0a74f7 100644
--- a/flatisfy/web/js_src/components/flatstable.vue
+++ b/flatisfy/web/js_src/components/flatstable.vue
@@ -56,13 +56,13 @@
diff --git a/flatisfy/web/js_src/components/flatstableline.vue b/flatisfy/web/js_src/components/flatstableline.vue
index 86bcf1b..e7e60dc 100644
--- a/flatisfy/web/js_src/components/flatstableline.vue
+++ b/flatisfy/web/js_src/components/flatstableline.vue
@@ -66,33 +66,33 @@ export default {
props: {
flat: Object,
showNotationColumn: Boolean,
- showNotes: Boolean,
+ showNotes: Boolean
},
computed: {
- capitalizedStatus() {
- return capitalize(this.$t('status.followed'));
+ capitalizedStatus () {
+ return capitalize(this.$t('status.followed'))
},
- photo() {
+ photo () {
if (this.flat.photos && this.flat.photos.length > 0) {
if (this.flat.photos[0].local) {
- return `/data/img/${this.flat.photos[0].local}`;
+ return `/data/img/${this.flat.photos[0].local}`
}
- return this.flat.photos[0].url;
+ return this.flat.photos[0].url
}
- return null;
- },
- notationRange() {
- return range(this.flat.notation);
+ return null
},
+ notationRange () {
+ return range(this.flat.notation)
+ }
},
methods: {
updateFlatStatus (id, status) {
this.$store.dispatch('updateFlatStatus', { flatId: id, newStatus: status })
- },
- },
-};
+ }
+ }
+}
diff --git a/flatisfy/web/routes/api.py b/flatisfy/web/routes/api.py
index d107cd5..101a821 100644
--- a/flatisfy/web/routes/api.py
+++ b/flatisfy/web/routes/api.py
@@ -10,6 +10,7 @@ import datetime
import itertools
import json
import re
+import os
import bottle
import vobject
@@ -146,7 +147,8 @@ def index_v1():
"flat": "/api/v1/flat/:id",
"search": "/api/v1/search",
"ics": "/api/v1/ics/visits.ics",
- "time_to_places": "/api/v1/time_to_places"
+ "time_to_places": "/api/v1/time_to_places",
+ "metadata": "/api/v1/metadata"
}
@@ -499,3 +501,31 @@ def opendata_postal_codes_v1(db):
}
except Exception as exc: # pylint: disable= broad-except
return JSONError(500, str(exc))
+
+def metadata_v1(config):
+ """
+ API v1 metadata of the application.
+
+ Example::
+
+ GET /api/v1/metadata
+
+ :return: The application metadata.
+ """
+ if bottle.request.method == 'OPTIONS':
+ # CORS
+ return {}
+
+ try:
+ ts_file = os.path.join(
+ config['data_directory'],
+ 'timestamp'
+ )
+ ts = os.path.getmtime(ts_file)
+ return {
+ 'data': {
+ 'last_update': ts
+ }
+ }
+ except Exception as exc: # pylint: disable= broad-except
+ return JSONError(500, str(exc))