You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/06/04 15:04:47 UTC
[incubator-ponymail-foal] branch master updated: Add first/last
Month data
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new e04ebb5 Add first/last Month data
e04ebb5 is described below
commit e04ebb55a7667a85676bd7a29f005b60bbd03d33
Author: Sebb <se...@apache.org>
AuthorDate: Fri Jun 4 16:03:05 2021 +0100
Add first/last Month data
---
server/endpoints/stats.py | 4 +++-
server/openapi.yaml | 8 ++++++++
server/plugins/mbox.py | 6 +++---
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/server/endpoints/stats.py b/server/endpoints/stats.py
index ef3b498..7a35af3 100644
--- a/server/endpoints/stats.py
+++ b/server/endpoints/stats.py
@@ -42,7 +42,7 @@ async def process(server: plugins.server.BaseServer, session: plugins.session.Se
wordcloud = None
if server.config.ui.wordcloud:
wordcloud = await plugins.mbox.wordcloud(session, query_defuzzed)
- first_year, last_year = await plugins.mbox.get_years(session, query_defuzzed_nodate)
+ first_year, last_year, first_month, last_month = await plugins.mbox.get_years(session, query_defuzzed_nodate)
threads = plugins.mbox.ThreadConstructor(results)
tstruct, authors = await server.runners.run(threads.construct)
@@ -64,6 +64,8 @@ async def process(server: plugins.server.BaseServer, session: plugins.session.Se
return {
"firstYear": first_year,
"lastYear": last_year,
+ "firstMonth": first_month,
+ "lastMonth": last_month,
"hits": len(results),
"numparts": len(authors),
"no_threads": len(tstruct),
diff --git a/server/openapi.yaml b/server/openapi.yaml
index 9159ce8..10574b8 100644
--- a/server/openapi.yaml
+++ b/server/openapi.yaml
@@ -219,10 +219,18 @@ components:
description: The first year found in the search results
type: integer
example: 2018
+ firstMonth:
+ description: The first month found in the search results
+ type: integer
+ example: 1
lastYear:
description: The last (most recent) year found within the search results
type: integer
example: 2021
+ lastMonth:
+ description: The last (most recent) month found in the search results
+ type: integer
+ example: 11
hits:
description: The total number of emails found in this search
type: integer
diff --git a/server/plugins/mbox.py b/server/plugins/mbox.py
index 4ecb2be..2a40387 100644
--- a/server/plugins/mbox.py
+++ b/server/plugins/mbox.py
@@ -435,7 +435,7 @@ async def get_years(session, query_defuzzed):
oldest = 1970
if res["hits"]["hits"]:
doc = res["hits"]["hits"][0]
- oldest = datetime.datetime.fromtimestamp(doc["_source"]["epoch"]).year
+ oldest = datetime.datetime.fromtimestamp(doc["_source"]["epoch"])
# Get youngest doc
res = await session.database.search(
@@ -444,9 +444,9 @@ async def get_years(session, query_defuzzed):
youngest = 1970
if res["hits"]["hits"]:
doc = res["hits"]["hits"][0]
- youngest = datetime.datetime.fromtimestamp(doc["_source"]["epoch"]).year
+ youngest = datetime.datetime.fromtimestamp(doc["_source"]["epoch"])
- return oldest, youngest
+ return oldest.year, youngest.year, oldest.month, youngest.month
class ThreadConstructor: