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

feat: Cron job to gather Github info and digest them to a SQLite database #592

Merged
merged 45 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
922fe9f
chore: upped sentry on `./api`
ZibanPirate Sep 3, 2024
a538ab4
feat: setup digest cron
ZibanPirate Sep 3, 2024
463d2c7
feat: setup sqlite database with an ts friendly orm
ZibanPirate Sep 3, 2024
a6893f6
chore: upgraded prettier
ZibanPirate Sep 3, 2024
a52fe06
feat: type-checked table against model
ZibanPirate Sep 3, 2024
60ec96e
fixed lint issues
ZibanPirate Sep 3, 2024
af16f60
added projects to database
ZibanPirate Sep 3, 2024
fe5079c
added repositories to database
ZibanPirate Sep 4, 2024
3a9e624
return id when upserting
ZibanPirate Sep 4, 2024
9a2462d
validate github response
ZibanPirate Sep 4, 2024
4bb4c52
added repo proj relation
ZibanPirate Sep 4, 2024
bd0cffa
better modeled project repo relation
ZibanPirate Sep 4, 2024
add5926
fixed linting error
ZibanPirate Sep 5, 2024
18d07fa
call get repo for repo health check instead of get langs
ZibanPirate Sep 5, 2024
1e966ac
replace forward slashes with hyphens sentry version
ZibanPirate Sep 5, 2024
d621c6c
chore: don't export GithubAccount class
ZibanPirate Sep 5, 2024
f30db43
Add db folder to oracle-cloud build
ZibanPirate Sep 5, 2024
67f0585
added contributions to database
ZibanPirate Sep 5, 2024
9f57d53
CRUD contributions
ZibanPirate Sep 6, 2024
cdcbf7b
refactored projects and contribs endpoints
ZibanPirate Sep 6, 2024
17e0707
added contributors to database
ZibanPirate Sep 6, 2024
fbfc9a3
populate contribution with project
ZibanPirate Sep 7, 2024
79c2c84
projects endpoint tweaks
ZibanPirate Sep 7, 2024
cd4598f
removed unused exports
ZibanPirate Sep 7, 2024
1406be1
model and create rel between contor and contion
ZibanPirate Sep 8, 2024
5d88230
contributors endpoint
ZibanPirate Sep 8, 2024
f85dad9
list all contributors
ZibanPirate Sep 8, 2024
56a63e0
list all contributors that are actual users
ZibanPirate Sep 8, 2024
3f7d8e5
updated snapshot tests
ZibanPirate Sep 8, 2024
f5a49a6
Merge pull request #594 from dzcode-io/feat/digest-contibutors
ZibanPirate Sep 8, 2024
7b2b9b9
Merge pull request #593 from dzcode-io/feat/digest-contibutions
ZibanPirate Sep 8, 2024
7ca03fb
remove old endpoints
ZibanPirate Sep 8, 2024
b936097
removed unused code
ZibanPirate Sep 8, 2024
b54f7fe
removed more unused code
ZibanPirate Sep 8, 2024
4429104
reordered deletions
ZibanPirate Sep 8, 2024
ef3bde8
refactor: Remove unused code and dependencies in team page
ZibanPirate Sep 8, 2024
441782b
chore: Update NODE_ENV validation in ENVDto
ZibanPirate Sep 8, 2024
6552e14
remove more unused code
ZibanPirate Sep 8, 2024
3adf341
capture exceptions in cron
ZibanPirate Sep 8, 2024
e723548
removed getUnsafe
ZibanPirate Sep 8, 2024
9c376eb
no dtos please
ZibanPirate Sep 8, 2024
47031a5
the only dto is in api now
ZibanPirate Sep 8, 2024
f297f2e
models extends BaseEntity
ZibanPirate Sep 8, 2024
430557b
no languages and labels for now
ZibanPirate Sep 8, 2024
ff443bd
sort projects based on score
ZibanPirate Sep 8, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ coverage
# api
api/oracle-cloud/build
api/fetch_cache
api/sqlite_db
api/nodemon.json

# web
Expand Down
48 changes: 48 additions & 0 deletions api/db/migrations/0000_sudden_doctor_doom.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
CREATE TABLE `contributions` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`title` text NOT NULL,
`updated_at` text NOT NULL,
`url` text NOT NULL,
`type` text NOT NULL,
`run_id` text NOT NULL,
`activity_count` integer NOT NULL,
`repository_id` integer NOT NULL,
`contributor_id` integer NOT NULL,
FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`contributor_id`) REFERENCES `contributors`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `contributors` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL,
`name` text NOT NULL,
`username` text NOT NULL,
`url` text NOT NULL,
`avatar_url` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `projects` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`name` text NOT NULL,
`slug` text NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL
);
--> statement-breakpoint
CREATE TABLE `repositories` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`provider` text NOT NULL,
`owner` text NOT NULL,
`name` text NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL,
`project_id` integer NOT NULL,
FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `contributions_url_unique` ON `contributions` (`url`);--> statement-breakpoint
CREATE UNIQUE INDEX `contributors_url_unique` ON `contributors` (`url`);--> statement-breakpoint
CREATE UNIQUE INDEX `projects_slug_unique` ON `projects` (`slug`);--> statement-breakpoint
CREATE UNIQUE INDEX `repositories_provider_owner_name_unique` ON `repositories` (`provider`,`owner`,`name`);
10 changes: 10 additions & 0 deletions api/db/migrations/0001_black_eternals.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE `contributor_repository_relation` (
`contributor_id` integer NOT NULL,
`repository_id` integer NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL,
`score` integer NOT NULL,
PRIMARY KEY(`contributor_id`, `repository_id`),
FOREIGN KEY (`contributor_id`) REFERENCES `contributors`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action
);
316 changes: 316 additions & 0 deletions api/db/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
{
"version": "6",
"dialect": "sqlite",
"id": "ba41012f-4495-42ff-ace1-61bd7eaef476",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"contributions": {
"name": "contributions",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"record_imported_at": {
"name": "record_imported_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"run_id": {
"name": "run_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"activity_count": {
"name": "activity_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"repository_id": {
"name": "repository_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"contributor_id": {
"name": "contributor_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"contributions_url_unique": {
"name": "contributions_url_unique",
"columns": ["url"],
"isUnique": true
}
},
"foreignKeys": {
"contributions_repository_id_repositories_id_fk": {
"name": "contributions_repository_id_repositories_id_fk",
"tableFrom": "contributions",
"tableTo": "repositories",
"columnsFrom": ["repository_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"contributions_contributor_id_contributors_id_fk": {
"name": "contributions_contributor_id_contributors_id_fk",
"tableFrom": "contributions",
"tableTo": "contributors",
"columnsFrom": ["contributor_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"contributors": {
"name": "contributors",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"record_imported_at": {
"name": "record_imported_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"run_id": {
"name": "run_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'initial-run-id'"
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"avatar_url": {
"name": "avatar_url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"contributors_url_unique": {
"name": "contributors_url_unique",
"columns": ["url"],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"projects": {
"name": "projects",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"record_imported_at": {
"name": "record_imported_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"slug": {
"name": "slug",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"run_id": {
"name": "run_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'initial-run-id'"
}
},
"indexes": {
"projects_slug_unique": {
"name": "projects_slug_unique",
"columns": ["slug"],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"repositories": {
"name": "repositories",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"record_imported_at": {
"name": "record_imported_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"owner": {
"name": "owner",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"run_id": {
"name": "run_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'initial-run-id'"
},
"project_id": {
"name": "project_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"repositories_provider_owner_name_unique": {
"name": "repositories_provider_owner_name_unique",
"columns": ["provider", "owner", "name"],
"isUnique": true
}
},
"foreignKeys": {
"repositories_project_id_projects_id_fk": {
"name": "repositories_project_id_projects_id_fk",
"tableFrom": "repositories",
"tableTo": "projects",
"columnsFrom": ["project_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
Loading
Loading