-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
with API key generation code removed... (so the code just panics) my code used to generate a lot of API keys to prevent rate-limiting (because i didn't want to wait many hours everytime) while fetching endpoints like projects_users, cursus_users, coalitions_users, etc.. (a full list is in internal/api/ratelimit.go) i tried for awhile to find better methods than this, but gave up because the API is very limiting. that resulted in high database loads on the intra (i was only fetching on one computer), causing issues to people doing their exams... also i've been told storing API data in a database (albeit shielding non-42 students from accessing it) is a violation of GDPR, so reusing this code might get you in legal trouble with 42 central.
- Loading branch information
0 parents
commit d96dd48
Showing
90 changed files
with
21,766 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INTRA_SESSION_TOKEN=... # _intra_42_session_production | ||
USER_ID_TOKEN=... # user.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=" | ||
|
||
use devenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.env | ||
*_templ.go | ||
db/42evaluators-dev.sqlite3 | ||
db/42evaluators-dev.sqlite3-journal | ||
.*.swp | ||
|
||
# Devenv | ||
.devenv* | ||
devenv.local.nix | ||
# direnv | ||
.direnv | ||
# pre-commit | ||
.pre-commit-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web/static/assets/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
TEMPL ?= templ | ||
GO ?= go | ||
|
||
default: dev | ||
|
||
TEMPLATES = $(patsubst %.templ,%_templ.go,$(wildcard web/templates/*.templ)) | ||
|
||
web/templates/%_templ.go: web/templates/%.templ | ||
$(TEMPL) generate -f $^ | ||
|
||
templates: $(TEMPLATES) | ||
|
||
dev: deps templates | ||
env $(FLAGS) $(GO) run $(GOFLAGS) cmd/*.go | ||
|
||
prod: GOFLAGS="-ldflags=-X github.com/demostanis/42evaluators/internal/api.defaultRedirectURI=https://42evaluators.com" | ||
prod: deps templates dev | ||
|
||
nojobs: FLAGS=disabledjobs=* | ||
nojobs: dev | ||
|
||
race: GOFLAGS+=-race | ||
race: dev | ||
|
||
debug: FLAGS=httpdebug=* | ||
debug: dev | ||
|
||
42evaluators: templates | ||
$(GO) build cmd/main.go -o $@ | ||
|
||
build: deps 42evaluators | ||
|
||
clean: | ||
$(RM) $(TEMPLATES) | ||
|
||
deps: | ||
@if ! which templ >/dev/null 2>&1 ; then \ | ||
$(GO) install github.com/a-h/templ/cmd/templ@latest; \ | ||
fi | ||
|
||
.PHONY: default templates dev build clean deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 42evaluators | ||
|
||
Welcome to the **42evaluators** GitHub repository! | ||
|
||
## Running | ||
|
||
We use [devenv](https://devenv.sh) for development. It provides an easy way to | ||
install and setup PostgreSQL (it's probably also possible to setup PostgreSQL | ||
separately. You might have to modify `internal/database/db.go` adequately). | ||
|
||
Once you've downloaded it, run `devenv up -d`. This runs PostgreSQL in the background | ||
(you can also remove the `-d` if you want to inspect the logs). Afterwards, you | ||
can enter the development shell with `devenv shell`. | ||
|
||
You need to fill `.env`. It contains credentials to connect to your account, | ||
which you can find in the "Storage" tab of the Devtools while you're on the 42 intra, | ||
to create API keys (to prevent rate limiting, because 42evaluators requires | ||
doing a LOT of API requests). See `.env.example`. | ||
|
||
Finally, you can use the Makefile to launch 42evaluators: `make` | ||
|
||
This will generate API keys, and start fetching a bunch of stuff (such as | ||
projects, which takes a lot of time...). You can open up `localhost:8080`. | ||
|
||
## Backstory | ||
|
||
A few months ago, some students from 42 Le Havre noticed 42evaluators.com went down. | ||
We decided to email the previous owner, @rfautier, to try to keep maintaining | ||
the code ourselves. | ||
|
||
After he agreed, we checked the code, but many parts of it would have needed to | ||
be replaced if we wanted to keep the code clean. | ||
|
||
Since I liked Go, I decided to rewrite it completly in Go. But the other students | ||
didn't like that language, so I ended up rewriting most of it myself. |
Oops, something went wrong.