diff options
| author | 2023-08-21 22:49:46 +0200 | |
|---|---|---|
| committer | 2023-08-21 22:49:46 +0200 | |
| commit | 1d00c4ef66060a185452f83ecf639e6d3a49baf5 (patch) | |
| tree | dce4449d170740627588a34d4c749b71b6e4a2d9 | |
| parent | Backport from xs. (diff) | |
| download | snac2-1d00c4ef66060a185452f83ecf639e6d3a49baf5.tar.gz snac2-1d00c4ef66060a185452f83ecf639e6d3a49baf5.tar.xz snac2-1d00c4ef66060a185452f83ecf639e6d3a49baf5.zip | |
The nodeinfo file returns more useful information.
| -rw-r--r-- | httpd.c | 32 |
1 files changed, 28 insertions, 4 deletions
| @@ -39,11 +39,35 @@ const char *nodeinfo_2_0_template = "" | |||
| 39 | xs_str *nodeinfo_2_0(void) | 39 | xs_str *nodeinfo_2_0(void) |
| 40 | /* builds a nodeinfo json object */ | 40 | /* builds a nodeinfo json object */ |
| 41 | { | 41 | { |
| 42 | xs *users = user_list(); | 42 | int n_utotal = 0; |
| 43 | int n_users = xs_list_len(users); | 43 | int n_umonth = 0; |
| 44 | int n_posts = 0; /* to be implemented someday */ | 44 | int n_uhyear = 0; |
| 45 | int n_posts = 0; | ||
| 46 | xs *users = user_list(); | ||
| 47 | xs_list *p; | ||
| 48 | char *v; | ||
| 49 | |||
| 50 | p = users; | ||
| 51 | while (xs_list_iter(&p, &v)) { | ||
| 52 | /* build the full path name to the last usage log */ | ||
| 53 | xs *llfn = xs_fmt("%s/user/%s/lastlog.txt", srv_basedir, v); | ||
| 54 | double llsecs = (double)time(NULL) - mtime(llfn); | ||
| 55 | |||
| 56 | if (llsecs < 60 * 60 * 24 * 30 * 6) { | ||
| 57 | n_uhyear++; | ||
| 58 | |||
| 59 | if (llsecs < 60 * 60 * 24 * 30) | ||
| 60 | n_umonth++; | ||
| 61 | } | ||
| 62 | |||
| 63 | n_utotal++; | ||
| 64 | |||
| 65 | /* build the file to each user public.idx */ | ||
| 66 | xs *pidxfn = xs_fmt("%s/user/%s/private.idx", srv_basedir, v); | ||
| 67 | n_posts += index_len(pidxfn); | ||
| 68 | } | ||
| 45 | 69 | ||
| 46 | return xs_fmt(nodeinfo_2_0_template, n_users, n_users, n_users, n_posts); | 70 | return xs_fmt(nodeinfo_2_0_template, n_utotal, n_umonth, n_uhyear, n_posts); |
| 47 | } | 71 | } |
| 48 | 72 | ||
| 49 | 73 | ||