Skip to content

Commit

Permalink
rename 'statistics' to 'status'
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed May 16, 2024
1 parent 0eb2f89 commit c79c611
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Welcome, fedinaut! localhost.localdomain:8443 is an instance of tootik, a federa
🔎 Search posts
📣 New post
⚙️ Settings
📊 Statistics
📊 Status
🛟 Help
```

Expand Down
4 changes: 2 additions & 2 deletions front/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* /search shows an input prompt and redirects to /hashtag.
* /hashtags shows a list of popular hashtags.
* /fts shows an input prompt and performs full-text search in posts.
* /stats shows statistics and server health metrics.
* /status shows statistics and server health metrics.

* /view shows a complete post with extra details like links in the post, a list mentioned users, a list of hashtags, a link to the author's outbox, a list of replies and a link to the parent post (if found).
* /thread displays a tree of replies in a thread.
Expand Down Expand Up @@ -44,7 +44,7 @@ Some clients generate a certificate for / (all pages of this capsule) when /foo
* /users/hashtag
* /users/hashtags
* /users/fts
* /users/stats
* /users/status
* /users/view
* /users/thread

Expand Down
4 changes: 2 additions & 2 deletions front/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ func NewHandler(domain string, closed bool, cfg *cfg.Config) (Handler, error) {
h.handlers[regexp.MustCompile(`^/fts$`)] = withUserMenu(h.fts)
h.handlers[regexp.MustCompile(`^/users/fts$`)] = withUserMenu(h.fts)

h.handlers[regexp.MustCompile(`^/stats$`)] = withCache(withUserMenu(h.stats), time.Minute*5, &cache, cfg)
h.handlers[regexp.MustCompile(`^/users/stats$`)] = withCache(withUserMenu(h.stats), time.Minute*5, &cache, cfg)
h.handlers[regexp.MustCompile(`^/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache, cfg)
h.handlers[regexp.MustCompile(`^/users/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache, cfg)

h.handlers[regexp.MustCompile(`^/oops`)] = withUserMenu(oops)
h.handlers[regexp.MustCompile(`^/users/oops`)] = withUserMenu(oops)
Expand Down
2 changes: 1 addition & 1 deletion front/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func writeUserMenu(w text.Writer, user *ap.Actor) {
w.Link("/users/settings", "⚙️ Settings")
}

w.Link(prefix+"/stats", "📊 Statistics")
w.Link(prefix+"/status", "📊 Status")
w.Link(prefix+"/help", "🛟 Help")
}

Expand Down
2 changes: 1 addition & 1 deletion front/static/help.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This page shows popular hashtags, allowing you to discover trends and shared int

This is a full-text search tool that lists posts containing keyword(s), ordered by relevance.

> 📊 Statistics
> 📊 Status

This page shows various statistics about this server and the parts of the fediverse it's connected to.

Expand Down
2 changes: 1 addition & 1 deletion front/static/users/help.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This page allows you to:
* Notify followers about account migration from this instance
* Upload a .png, .jpg or .gif image to serve as your avatar (use your client certificate for authentication): up to {{.Config.MaxAvatarWidth}}x{{.Config.MaxAvatarHeight}} and {{.Config.MaxAvatarSize}} bytes, downscaled to {{.Config.AvatarWidth}}x{{.Config.AvatarHeight}}

> 📊 Statistics
> 📊 Status

This page shows various statistics about this server and the parts of the fediverse it's connected to.

Expand Down
4 changes: 2 additions & 2 deletions front/stats.go → front/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func getActiveUsersGraph(r *request) string {
return getGraph(r, `select strftime('%Y-%m-%d', datetime(day, 'unixepoch')), count(distinct author) from (select notes.inserted/(60*60*24)*60*60*24 as day, persons.id as author from notes join persons on persons.id = notes.author where notes.inserted>unixepoch()-60*60*24*7 and notes.inserted<unixepoch()/(60*60*24)*60*60*24) group by day`, keys, values)
}

func (h *Handler) stats(w text.Writer, r *request, args ...string) {
func (h *Handler) status(w text.Writer, r *request, args ...string) {
var usersCount, postsCount, postsToday, federatedPostsCount, federatedPostsToday int64
var lastPost, lastFederatedPost, lastRegister, lastFederatedUser sql.NullInt64
var outboxSize, inboxSize int
Expand Down Expand Up @@ -167,7 +167,7 @@ func (h *Handler) stats(w text.Writer, r *request, args ...string) {

w.OK()

w.Title("📊 Statistics")
w.Title("📊 Status")

if dailyPostsGraph != "" {
w.Subtitle("Posts Per Hour")
Expand Down
12 changes: 6 additions & 6 deletions test/stats_test.go → test/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import (
"testing"
)

func TestStats_NewInstance(t *testing.T) {
func TestStatus_NewInstance(t *testing.T) {
server := newTestServer()
defer server.Shutdown()

assert := assert.New(t)

stats := server.Handle("/stats", server.Alice)
assert.Regexp("^20 text/gemini\r\n", stats)
status := server.Handle("/status", server.Alice)
assert.Regexp("^20 text/gemini\r\n", status)
}

func TestStats_WithPosts(t *testing.T) {
func TestStatus_WithPosts(t *testing.T) {
server := newTestServer()
defer server.Shutdown()

Expand All @@ -40,6 +40,6 @@ func TestStats_WithPosts(t *testing.T) {
whisper := server.Handle("/users/whisper?Hello%20world", server.Alice)
assert.Regexp(`^30 /users/view/\S+\r\n$`, whisper)

stats := server.Handle("/stats", server.Alice)
assert.Regexp("^20 text/gemini\r\n", stats)
status := server.Handle("/status", server.Alice)
assert.Regexp("^20 text/gemini\r\n", status)
}

0 comments on commit c79c611

Please sign in to comment.