Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo entire stats server #2

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
11bc09c
Initial commit
PofMagicfingers Jan 11, 2018
c53ffb2
Boilerplate
PofMagicfingers Jan 11, 2018
f80edba
Add geoip
PofMagicfingers Jan 15, 2018
8c07904
Add models
PofMagicfingers Jan 16, 2018
d01aa3b
First working concept
PofMagicfingers Jan 20, 2018
e0b91f4
Rename to figures
PofMagicfingers Jan 23, 2018
c5507c3
Add travis deployment
PofMagicfingers Jan 23, 2018
7568b90
Add feed id
PofMagicfingers Jan 23, 2018
853867e
Update deploy key
PofMagicfingers Jan 23, 2018
9ff2ee1
Add stats bin wrapper
PofMagicfingers Jan 26, 2018
b15afea
Fix feed id
PofMagicfingers Jan 27, 2018
d3753c9
Fix algorithms
PofMagicfingers Jan 27, 2018
636f060
Fix stats config
PofMagicfingers Jan 27, 2018
5b88d7a
Add missing line
PofMagicfingers Jan 29, 2018
7e24e03
Better structure
PofMagicfingers Jan 30, 2018
2ddbff9
Build releases
PofMagicfingers Jan 30, 2018
c66d59d
Fix Mongo exports and add better connection handling
PofMagicfingers Jan 30, 2018
e95b735
Build release
PofMagicfingers Jan 30, 2018
88f18d6
Fix exporting
PofMagicfingers Jan 30, 2018
b6753b0
Export as UMD module
PofMagicfingers Jan 30, 2018
2ffdd0e
Export correctly module
PofMagicfingers Jan 30, 2018
59963f9
Make maxmind dist compatible
PofMagicfingers Jan 30, 2018
6c8dd50
Fix _DIST undefined
PofMagicfingers Jan 30, 2018
f0c3cb4
Bump package version
PofMagicfingers Jan 30, 2018
8405044
Update build
PofMagicfingers Jan 30, 2018
54373b5
Some packages
PofMagicfingers Mar 14, 2018
19eb827
Add some configurations
PofMagicfingers Mar 25, 2018
bcc78ba
First migration
PofMagicfingers Mar 25, 2018
3d2f2be
Fix some configuration
PofMagicfingers Mar 25, 2018
f9d0fcc
Update and add migration
PofMagicfingers Apr 9, 2018
5b68cdf
Reset development to fresh boilerplate
PofMagicfingers Apr 22, 2018
9472aa5
bite
PofMagicfingers Apr 22, 2018
be078c7
Add hello world
PofMagicfingers Apr 24, 2018
89306a5
Add tests and issuers keys
PofMagicfingers Apr 25, 2018
0a19b19
Add some stuff
PofMagicfingers Apr 26, 2018
a7e705e
Split into modules
PofMagicfingers Apr 30, 2018
8c68140
Add cassandra docker
PofMagicfingers Apr 30, 2018
1f2087d
Add dev environment helpers
PofMagicfingers Apr 30, 2018
58ff7b2
Start docker before running migrations
PofMagicfingers May 1, 2018
ce06eb5
Add migrations scripts
PofMagicfingers May 2, 2018
ae0b127
Change to postgresql
PofMagicfingers Jun 5, 2018
c79c2a7
Connect (well, no) to postgres
PofMagicfingers Jun 6, 2018
413c86e
Working insert, and working tests
PofMagicfingers Jun 14, 2018
62cb0da
Add test config for travis
PofMagicfingers Jun 16, 2018
0b840c9
Run migrations before tests
PofMagicfingers Jun 16, 2018
619b92d
Add maxmind
PofMagicfingers Jun 16, 2018
e534943
Add parsing values and prettier
PofMagicfingers Jun 18, 2018
496bbab
Add real insertion test
PofMagicfingers Jun 20, 2018
f7fd81d
View saved with RGPD compliance (scrambled IP)
PofMagicfingers Jun 24, 2018
bd7a1fb
Get back rss issuer key
PofMagicfingers Jun 24, 2018
d703659
Almost add authentication
PofMagicfingers Jun 24, 2018
6b51a2a
Add some testing for AuthRequest
PofMagicfingers Jun 25, 2018
f5d1572
Fix and add tests
PofMagicfingers Jun 26, 2018
cb6aaac
Add back codecov
PofMagicfingers Jun 26, 2018
ce056ce
Added auth tests
PofMagicfingers Jun 27, 2018
585966f
Add tests servers
PofMagicfingers Jun 28, 2018
2ad3b49
Rewriting server
PofMagicfingers Jun 29, 2018
479d5a2
Fix GraphQL server
Jul 3, 2018
e2e3969
Add end to end testing, and fix authentication
PofMagicfingers Jul 3, 2018
2c68c05
Fully test authentication
Jul 4, 2018
0f1e2db
Add todo
Jul 4, 2018
1d20019
Clean code and add heartbeat
PofMagicfingers Jul 5, 2018
fb37456
Cleaning and heartbeat
Jul 10, 2018
19d3a31
Count daily views into view_counts
Jul 17, 2018
5c87e05
Attempt to simplify code
Sep 3, 2018
c652c98
Clean code
PofMagicfingers Sep 4, 2018
fbbe2a7
Fix tests
PofMagicfingers Sep 4, 2018
ced14a7
Update node version
PofMagicfingers Sep 4, 2018
c6921ac
Fix travis tests
PofMagicfingers Sep 4, 2018
e66e70a
Update TODO
PofMagicfingers Sep 4, 2018
a0b3caa
Detect bots
PofMagicfingers Sep 5, 2018
4fa42e1
Add more tests to ComputeViewCounts
PofMagicfingers Sep 7, 2018
bba95ed
Fix monthly_timecode
Sep 15, 2018
8083eef
Archive and delete old views
Sep 15, 2018
773b13d
Add queries to get archives
Sep 16, 2018
90f5e64
Add query to get view counts
Sep 16, 2018
dc4d5c8
Only delete archived views
Sep 16, 2018
8274be9
Clean debug variables
Sep 16, 2018
326eb6d
Fix all tests
Sep 16, 2018
9d19f37
Keeps track of display names
Oct 22, 2018
2b493d0
Update travis config
Oct 30, 2018
86e650a
Merge branch 'new/graphql' into develop
Oct 30, 2018
1907d30
Update node version in travis
Oct 30, 2018
2198b52
Use node v10 in travis
Nov 1, 2018
663d5a5
Merge branch 'feature/update-node' into develop
Nov 1, 2018
9ae389d
Start app after deployment
Nov 1, 2018
4a61915
Add docker dev instance
Nov 14, 2018
13c54c3
Add missing field
Jan 1, 2019
a53d83e
Fix feed_id type
Jan 1, 2019
19d3eda
Add timestamps to display names
Jan 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
{
"presets": [
[
"env",
{
"targets": {
"node": "6.10"
}
}
]
],
"plugins": [
[
"babel-plugin-root-import",
[
{
"rootPathPrefix": "~",
"rootPathSuffix": "src"
}
]
],
"transform-object-rest-spread",
[
"babel-plugin-transform-builtin-extend",
{
"globals": ["Error", "Array"]
}
]
]
"presets": ["env"],
"plugins": ["transform-object-rest-spread", "import-graphql"]
}
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2018,
"sourceType": "module",
"env": { "es6": true, "node": true }
"env": { "es6": true, "node": true },
"ecmaFeatures": {
"spread": true
}
},
"extends": ["prettier"],
"plugins": ["prettier"],
Expand Down
6 changes: 6 additions & 0 deletions .graphqlconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
projects:
app:
schemaPath: "src/graphql/schema.graphql"
extensions:
endpoints:
default: "http://localhost:5000"
41 changes: 24 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
language: node_js
sudo: false
node_js:
- 6.11.3
- 10
install:
- npm install
- yarn install
addons:
postgresql: "9.6"
services:
- postgresql
env:
- NODE_ENV=test
- NODE_ENV=travis
before_script:
- psql -c 'create database podcloud_stats_test;' -U postgres
- NODE_ENV=travis npm run db-migrate up
script:
- npm run codecov
- NODE_ENV=travis yarn codecov
before_deploy:
- openssl aes-256-cbc -K $encrypted_17c9c2b55791_key -iv $encrypted_17c9c2b55791_iv
-in .deploy_rsa.enc -out /tmp/deploy_rsa -d
- eval "$(ssh-agent -s)"
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
- openssl aes-256-cbc -K $encrypted_17c9c2b55791_key -iv $encrypted_17c9c2b55791_iv
-in .deploy_rsa.enc -out /tmp/deploy_rsa -d
- eval "$(ssh-agent -s)"
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
deploy:
- provider: script
script: "./deploy.sh preprod"
on:
branch: develop
- provider: script
script: "./deploy.sh production"
on:
branch: master
- provider: script
script: "./deploy.sh preprod"
on:
branch: develop
- provider: script
script: "./deploy.sh production"
on:
branch: master
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# podcloud-stats
Stats gateway for podCloud

### Generate issuers_keys

`yarn new_issuer_key`
24 changes: 24 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# TODO

## Stats
- [x] GraphQL Server
- [x] Authentication system
- [x] Mutation to save view
- [x] Support all view sources
- [x] Support bot detection
- [x] Executable task to calculate view counts daily and monthly
- [x] Archive old views into CSV monthly
- [x] Query to get view counts
- [x] Query to get archives urls
- [x] Handler to get archives CSV file
- [x] Keep track of feed display name
- [ ] Script to import old view counts

## RSS
- [ ] Generate auth tokens
- [ ] Save RSS views

## Legacy
- [ ] Generate auth tokens
- [ ] Save site views
- [ ] Get view counts
2 changes: 2 additions & 0 deletions archives/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
8 changes: 0 additions & 8 deletions bin/stats

This file was deleted.

26 changes: 26 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require("fs");
const path = require("path");

const IssuersKeys = {};

const _issuers_key_folder = path.resolve(__dirname, "./issuers_keys");
fs.readdirSync(_issuers_key_folder).forEach(file => {
const extensionMatch = file.match(/(.*)(\.pub)$/i);
const key =
extensionMatch && extensionMatch.length > 1
? extensionMatch[1]
: (file === "debug.key" && file) || null;

if (key) {
IssuersKeys[key.replace(".", "_")] = fs.readFileSync(
path.resolve(_issuers_key_folder, file),
"utf-8"
);
}
});

module.exports = {
IssuersKeys,
csvDir: path.resolve(__dirname, "../archives/"),
noAuth: !!process.env.NO_AUTH
};
4 changes: 0 additions & 4 deletions config/default.json

This file was deleted.

14 changes: 14 additions & 0 deletions config/development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import process from "process";

const DISABLE_AUTH = true;

module.exports = {
port: 80,
workers: 1,
postgres: {
user: "postgres",
host: "db",
database: "podcloud_stats_dev"
},
noAuth: DISABLE_AUTH
};
2 changes: 2 additions & 0 deletions config/issuers_keys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.key
!debug.key
51 changes: 51 additions & 0 deletions config/issuers_keys/debug.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAyBFdNu48bZHnJZ8fqCrfN2W0BJWhsWd9EBa2rHXQeW7FGpF/
FPu/6pJGmCI+MJoD7TNphefEsXDuvc6+QDDNB8r0UHHHicG7e0QxPitPxtkCCC6c
fdlWAzmMD1vuwXAzUrcN+yPHW5RVi+Rlp3EQBUi6vtvv6dkcDoIGPTrWDXfRylzB
iyhIr2Xa4KxGtEJtEhG/szSI8ou+u/p5wgFBMMC2J/TzttkzFYa3xiqS0wpmG73x
LnnR9n0a7FZflDOctOhhjBqMD54h9AAJeqYdXNdL+9mE5mYa+eEDB++xDpeuzY63
9P++s5OzHmxb/TbRnj6gCD8txH38ficilgyNIL52UkYTI/Jkr4rB85wht40qkM7W
Pz67KqT7CZP0T5hPpmBUa6juHmaUYwmo9dpV3+iGojQw5KiSawF81GU3rO/41fyK
z37yDZBsrKjL7NGIgjHWMTkmmCsIgFz/bV7SzDIyhInbaclGhYS25s5Hpf6vZw3B
RiHf04OZcnTF2OgiJhNlY137KyNAZt3YYyekaEEqNggO06ADXFePBG7jch3CJ8KS
D0ok4FNLwcplvhQ63Mkt5qpHsQqa0+NkHPbFkMLlUHU2xZLN7ZMRH/Ks6f5qGF4e
3qKR9VDWze5EUs61LowKJ8Q6nJwYyITdh8bqUZ+pNsA/5n5sG55j6L69yYkCAwEA
AQKCAgALvzlB6GsT4+U2iElLjnjcv9P6EO8Vg4YMU8kWBzTebGqWTMSxbrau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RiMARVUl5OEJIyAy4pLF9DtYn8EFuAmnP2qg20zEShWe
4Xu0HwPi7HuBx+4UdWAD1mrETflM1J07p6k7er8GiF55xeCLKCz5pytS4EfwUKrV
+A+zweNNzq0at5xc6NpUwlQZrVxUT56cJL2B4QWwgD8E3nBavOTMVbb657EI1W90
pET4jjfCgiKLllYH1fcDBj3Lt+ocZR5Fc4/VtFzl/vsBoe5Fp7v4Fe9lBaDY
-----END RSA PRIVATE KEY-----
14 changes: 14 additions & 0 deletions config/issuers_keys/debug.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyBFdNu48bZHnJZ8fqCrf
N2W0BJWhsWd9EBa2rHXQeW7FGpF/FPu/6pJGmCI+MJoD7TNphefEsXDuvc6+QDDN
B8r0UHHHicG7e0QxPitPxtkCCC6cfdlWAzmMD1vuwXAzUrcN+yPHW5RVi+Rlp3EQ
BUi6vtvv6dkcDoIGPTrWDXfRylzBiyhIr2Xa4KxGtEJtEhG/szSI8ou+u/p5wgFB
MMC2J/TzttkzFYa3xiqS0wpmG73xLnnR9n0a7FZflDOctOhhjBqMD54h9AAJeqYd
XNdL+9mE5mYa+eEDB++xDpeuzY639P++s5OzHmxb/TbRnj6gCD8txH38ficilgyN
IL52UkYTI/Jkr4rB85wht40qkM7WPz67KqT7CZP0T5hPpmBUa6juHmaUYwmo9dpV
3+iGojQw5KiSawF81GU3rO/41fyKz37yDZBsrKjL7NGIgjHWMTkmmCsIgFz/bV7S
zDIyhInbaclGhYS25s5Hpf6vZw3BRiHf04OZcnTF2OgiJhNlY137KyNAZt3YYyek
aEEqNggO06ADXFePBG7jch3CJ8KSD0ok4FNLwcplvhQ63Mkt5qpHsQqa0+NkHPbF
kMLlUHU2xZLN7ZMRH/Ks6f5qGF4e3qKR9VDWze5EUs61LowKJ8Q6nJwYyITdh8bq
UZ+pNsA/5n5sG55j6L69yYkCAwEAAQ==
-----END PUBLIC KEY-----
4 changes: 0 additions & 4 deletions config/preprod.json

This file was deleted.

4 changes: 0 additions & 4 deletions config/production.json

This file was deleted.

7 changes: 7 additions & 0 deletions config/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
postgres: {
user: "postgres",
host: "db",
database: "podcloud_stats_test"
}
};
4 changes: 0 additions & 4 deletions config/test.json

This file was deleted.

9 changes: 9 additions & 0 deletions config/travis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const test = require("./test");

module.exports = {
...test,
postgres: {
...test.postgres,
host: "localhost"
}
};
39 changes: 39 additions & 0 deletions database.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"defaultEnv": {
"ENV": "NODE_ENV"
},
"development": {
"driver": "pg",
"user": "postgres",
"password": "postgres",
"host": "db",
"database": "podcloud_stats_dev"
},
"test": {
"driver": "pg",
"user": "postgres",
"password": "postgres",
"host": "db",
"database": "podcloud_stats_test"
},
"travis": {
"driver": "pg",
"user": "postgres",
"password": "postgres",
"host": "localhost",
"database": "podcloud_stats_test"
},
"production": {
"driver": "pg",
"host": {
"ENV": "DB_HOST"
},
"user": {
"ENV": "DB_USERNAME"
},
"password": {
"ENV": "DB_PASSWORD"
},
"database": "podcloud_stats"
}
}
Loading