From 383d633d7d34162a28e34461b2ebd8939dc2038d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 13 Nov 2019 15:15:08 +0000 Subject: [PATCH] Function for monthly active accounts --- utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils.py b/utils.py index a9b3f708..5244a26d 100644 --- a/utils.py +++ b/utils.py @@ -388,6 +388,26 @@ def noOfAccounts(baseDir: str) -> bool: accountCtr+=1 return accountCtr +def noOfActiveAccountsMonthly(baseDir: str) -> bool: + """Returns the number of accounts on the system this month + """ + accountCtr=0 + currTime=int(time.time()) + monthSeconds=60*60*24*30 + for subdir, dirs, files in os.walk(baseDir+'/accounts'): + for account in dirs: + if '@' in account: + if not account.startswith('inbox@'): + lastUsedFilename=baseDir+'/accounts/'+account+'/.lastUsed' + if os.path.isfile(lastUsedFilename): + with open(lastUsedFilename, 'r') as lastUsedFile: + lastUsed = lastUsedFile.read() + if lastUsed.isdigit(): + timeDiff=(currTime-int(lastUsed)) + if timeDiff bool: """Returns true if the given post is public """