Git Product home page Git Product logo

go-u8views's Introduction

Yaroslav Podorvanov profile views

Profile views counter

Yaroslav Podorvanov profile views

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
FROM profile_hourly_views_stats
GROUP BY 1
ORDER BY 1;
Month Views Users
2023-01-01 15 3
2023-02-01 438 18
2023-03-01 951 32
2023-04-01 1110 36
2023-05-01 2191 43
2023-06-01 3433 57
2023-07-01 3331 54
2023-08-01 4539 69
2023-09-01 4519 77
2023-10-01 4473 78
2023-11-01 4919 96
2023-12-01 5525 115
2024-01-01 11130 231

go-u8views's People

Contributors

yaroslavpodorvanov avatar victorpoprozhuk avatar dmitry-shylov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.