Skip to content

Commit

Permalink
my last work on 42evaluators
Browse files Browse the repository at this point in the history
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
demostanis committed Apr 29, 2024
0 parents commit d96dd48
Show file tree
Hide file tree
Showing 90 changed files with 21,766 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
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
3 changes: 3 additions & 0 deletions .envrc
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
13 changes: 13 additions & 0 deletions .gitignore
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
1 change: 1 addition & 0 deletions .rgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web/static/assets/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions Makefile
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
35 changes: 35 additions & 0 deletions README.md
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.
Loading

0 comments on commit d96dd48

Please sign in to comment.