Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

u8views/go-u8views

Open more actions menu

Repository files navigation

u8views profile views

Profile views counter

Yaroslav Podorvanov profile views

Articles

Development

Start local development session
cp .local.env .env
make env-up
make migrate-all-reset
make postgres-fixtures
make postgres-fixtures-count
# and
# make postgres-fixtures-clear
Run after code changes
make env-up
End development session
make env-down
# or
# make env-down-with-clear
Benchmark (PC) Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
BENCHTIME=100x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12    	     100	    627990 ns/op	    5033 B/op	      80 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	0.088s
BENCHTIME=1000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12    	    1000	    449478 ns/op	    4124 B/op	      72 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	0.471s
BENCHTIME=10000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12    	   10000	    546875 ns/op	    4885 B/op	      81 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	5.492s
Benchmark (vultr.com VPS 1024.00 MB High Frequency) Intel Core Processor (Skylake, IBRS)
BENCHTIME=100x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 	     100	   2275173 ns/op	    1562 B/op	      43 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	0.360s
BENCHTIME=1000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 	    1000	   2121516 ns/op	    1571 B/op	      44 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	2.153s
BENCHTIME=10000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 	   10000	   2153319 ns/op	    1574 B/op	      44 allocs/op
PASS
ok  	github.com/u8views/go-u8views/internal/tests	21.566s

Database schema templates

Database schema

Database schema

SQL

SELECT user_id, SUM(count), COUNT(*)
FROM profile_hourly_views_stats
GROUP BY user_id
ORDER BY SUM(count) DESC
LIMIT 100;
SELECT g.time::TIMESTAMP
FROM (
    SELECT time::TIMESTAMP
    FROM GENERATE_SERIES(
        (DATE_TRUNC('DAY', NOW()) - INTERVAL '1 MONTH')::TIMESTAMP,
        (DATE_TRUNC('DAY', NOW()))::TIMESTAMP,
        '1 DAY'::INTERVAL
    ) AS time
) AS g;

Stats

SELECT DATE_TRUNC('MONTH', time) AS month,
       COUNT(*)                  AS views,
       COUNT(DISTINCT (user_id)) AS users,
       SUM("count")              AS total
FROM profile_hourly_views_stats
GROUP BY 1
ORDER BY 1;
Month Views Users Total
2023-01-01 15 3 78
2023-02-01 438 18 2700
2023-03-01 951 32 10241
2023-04-01 1110 36 3441
2023-05-01 2191 43 9032
2023-06-01 3433 57 16866
2023-07-01 3331 54 14233
2023-08-01 4539 69 18017
2023-09-01 4519 77 17053
2023-10-01 4473 78 15771
2023-11-01 4919 96 17567
2023-12-01 5525 115 19882
2024-01-01 11185 232 40202
2024-02-01 11348 245 39586
2024-03-01 13581 273 48629
2024-04-01 13613 291 47198
2024-05-01 14655 306 50581
2024-06-01 13924 319 57695
2024-07-01 14589 338 55751
2024-08-01 15593 380 51997
2024-09-01 16034 400 54388
2024-10-01 16599 455 56601
2024-11-01 16500 474 56818
2024-12-01 16511 483 58579
2025-01-01 19778 534 67856
2025-02-01 18914 597 112192
2025-03-01 20892 611 70920
2025-04-01 20738 630 67782
2025-05-01 21916 638 125460
2025-06-01 20758 689 62625
2025-07-01 23749 688 2407710
2025-08-01 23726 686 78508
2025-09-01 24146 727 87879
2025-10-01 25860 758 85042
2025-11-01 28348 830 84664
2025-12-01 37425 882 93729
2026-01-01 40140 889 121395
2026-02-01 35127 890 106999
SELECT                                    
    DATE_TRUNC('month', created_at),
    COUNT(*)                
FROM users                               
GROUP BY 1                     
ORDER BY 1;
Month Users
2023-01-01 3
2023-02-01 24
2023-03-01 29
2023-04-01 15
2023-05-01 23
2023-06-01 37
2023-07-01 7
2023-08-01 33
2023-09-01 27
2023-10-01 23
2023-11-01 37
2023-12-01 53
2024-01-01 189
2024-02-01 65
2024-03-01 62
2024-04-01 65
2024-05-01 49
2024-06-01 50
2024-07-01 52
2024-08-01 74
2024-09-01 87
2024-10-01 107
2024-11-01 91
2024-12-01 88
2025-01-01 98
2025-02-01 133
2025-03-01 90
2025-04-01 107
2025-05-01 76
2025-06-01 88
2025-07-01 105
2025-08-01 67
2025-09-01 125
2025-10-01 81
2025-11-01 132
2025-12-01 151
2026-01-01 133
2026-02-01 103

About

GitHub profile views tracker: displaying monthly view statistics

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.