tweaked neighbor view to show last update time instead of feels count

master
endorphant 2016-05-10 12:14:53 -04:00
parent 92e2f3731e
commit ed2a14b846
4 changed files with 41 additions and 4 deletions

View File

@ -5,6 +5,6 @@
| |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ | | |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ |
| | |___ |___ |___ ___] |___ | \| |__] | | \| |___ | | | |___ |___ |___ ___] |___ | \| |__] | | \| |___ |
| | | |
| ver 0.6 (fairly unstable) | | ver 0.6.5 (fairly unstable) |
| ~endorphant/projects/ttbp/changelog.txt | | ~endorphant/projects/ttbp/changelog.txt |
|__________________________________________________________| |__________________________________________________________|

View File

@ -10,6 +10,7 @@ import json
import core import core
import chatter import chatter
import inflect import inflect
import util
## system globals ## system globals
SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin") SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin")
@ -340,10 +341,12 @@ def view_neighbors(users):
count += 1 count += 1
lastfile = os.path.join("/home", user, ".ttbp", "entries", filename) lastfile = os.path.join("/home", user, ".ttbp", "entries", filename)
date = "" ago = "never"
if lastfile: if lastfile:
last = os.path.getctime(lastfile) last = os.path.getctime(lastfile)
date = time.strftime("%Y%m%d %H%M", time.localtime(last)) #date = time.strftime("%Y%m%d %H%M", time.localtime(last))
since = time.time()-last
ago = util.pretty_time(int(since)) + " ago"
else: else:
last = 0 last = 0
@ -354,7 +357,8 @@ def view_neighbors(users):
if len(user) < 8: if len(user) < 8:
user += "\t" user += "\t"
userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+")", last]) userList.append(["\t"+user+"\t"+url+pad+"\t("+ago+")", last])
#userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+")", last])
#userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+") "+date, last]) #userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+") "+date, last])
# sort user by most recent entry # sort user by most recent entry

29
bin/util.py 100644
View File

@ -0,0 +1,29 @@
#!/usr/bin/python
import inflect
import time
p = inflect.engine()
def pretty_time(time):
m, s = divmod(time, 60)
if m > 0:
h, m = divmod(m, 60)
if h > 0:
d, h = divmod(h, 24)
if d > 0:
w, d = divmod(d, 7)
if w > 0:
mo, w = divmod(w, 4)
if mo > 0:
return p.no("month", mo)
else:
return p.no("week", w)
else:
return p.no("day", d)
else:
return p.no("hour", h)
else:
return p.no("minute", m)
else:
return p.no("second", s)

View File

@ -28,6 +28,10 @@ TO-DO:
CHANGELOG: CHANGELOG:
ver 0.6.5
-renamed FEELS ENGINE
-changed neighbor view to show last update time instead of feels count
ver 0.6 ver 0.6
-improving exit handling -improving exit handling
-sort neighbor view by most recently updated -sort neighbor view by most recently updated