Don't display result table when there is no results

This commit is contained in:
Simon 2018-08-09 19:59:37 -04:00
parent c0891aa5e1
commit faf0eee0fd
2 changed files with 27 additions and 23 deletions

1
od_database Submodule

@ -0,0 +1 @@
Subproject commit 1ff1e039f5aed3394cd9ff0f0e6e4b88d3b0618e

View File

@ -90,8 +90,9 @@ class OdDatabase:
@staticmethod @staticmethod
def format_search_hits(hits, query): def format_search_hits(hits, query):
message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`: \n\n" message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`"
message += "File | Size | Date \n" if hits["hits"]["total"] > 0:
message += ": \n\n"
message += ":-- | :-- | --: \n" message += ":-- | :-- | --: \n"
for hit in hits["hits"]["hits"]: for hit in hits["hits"]["hits"]:
@ -117,6 +118,8 @@ class OdDatabase:
message += hl_name + ("." if src["ext"] else "") + src["ext"] + " | " message += hl_name + ("." if src["ext"] else "") + src["ext"] + " | "
message += humanfriendly.format_size(src["size"]) + " | " message += humanfriendly.format_size(src["size"]) + " | "
message += time.strftime("%Y-%m-%d", time.gmtime(src["mtime"])) + " \n" message += time.strftime("%Y-%m-%d", time.gmtime(src["mtime"])) + " \n"
else:
message += "\n"
message += "\n[More results for this query](https://od-db.the-eye.eu/search?q=" + query + ") |" \ message += "\n[More results for this query](https://od-db.the-eye.eu/search?q=" + query + ") |" \
" [OD-Database](https://od-db.the-eye.eu/)" " [OD-Database](https://od-db.the-eye.eu/)"