puzzle / skills

Open source skill management web application
GNU Affero General Public License v3.0
60 stars 18 forks source link

Write ID Mapper-Script | PuzzleTime Sync #2 #735

Open RandomTannenbaum opened 2 months ago

RandomTannenbaum commented 2 months ago

Introduction At the moment we have the problem that we have no way of knowing which record from the PuzzleSkills DB belongs to which record from the PuzzleTime DB. We can't do this by name or similar because we can't ensure these are atomic and consistent with our data. To solve this problem we have to map the values initially, so we later know if a record is new or already exists.

To know this we essentially want a foreign key on every person record in PuzzleSkills that references the primary keys from person records in PuzzleTime. So the first step is to create a db migration to add this new field.

For the initial mapping an idea was to write a mapper script that tries to find as many matching records as possible by using an attribute like the name. The matches that are unambiguous can then be mapped automatically. Ambiguous matches or unmatched entries should be sorted out by the script for manual mapping and confirmation.

ToDo

RandomTannenbaum commented 2 months ago

Stand 21.06.2024 Ich habe die Migration erstellt. Ausserdem habe ich angefangen das Mapper Skript zu schreiben. Dieses kann jetzt sowohl Daten aus dem Puzzle Skills als auch aus dem Puzzle Time per http Request abfragen.

Postman kann übrigens aus den gesendeten Requests direkt den zugehörigen Ruby Code generieren 😉

RandomTannenbaum commented 2 months ago

Stand 27.06.2024 Das ist script ist nun fertig und auch tests dazu mit Hilfe von webmock sind geschrieben. Ausserdem haben wir einen PTime-API client geschrieben, mit dem man die get abfragen an die PuzzleTime API ausführen kann.

Das script ist über die Rake Task rake ptime:assign ausführbar. Diese task führt das Mapping direkt durch. Es gibt aber noch die zweite Rake Task: rake ptime:evaluate_assign. Diese macht das Selbe wie die erste Task, nur werden die IDs noch nicht assigned. Dadurch kann man einen dry-run ausführen, um vorher schon zu überprüfen, welche Personen aus dem Times gemapt werden können.