about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--usercount.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/usercount.go b/usercount.go
index 180c573..37b8697 100644
--- a/usercount.go
+++ b/usercount.go
@@ -11,10 +11,18 @@ import (
 func userCountQuery(format string) ([]byte, error) {
 	ls, err := exec.Command("/bin/ls", "/home").Output()
 	if err != nil {
-		return nil, fmt.Errorf("Couldn't execute ls: %w", err)
+		return nil, fmt.Errorf("User Count Query: %w", err)
 	}
 
 	split := strings.Fields(string(ls))
+	total := 0
+
+	for _, e := range split {
+		if strings.HasPrefix(e, ".") || strings.HasPrefix(e, "_") {
+			continue
+		}
+		total++
+	}
 
 	if format == "plain" {
 		return []byte(fmt.Sprintf("%v users\n", len(split))), nil
@@ -23,7 +31,7 @@ func userCountQuery(format string) ([]byte, error) {
 	out := fmt.Sprintf(`{
 	"userCount": "%v"
 }
-`, len(split))
+`, total)
 
 	return []byte(out), nil
 }