Skip to content

Commit

Permalink
Merge pull request #592 from dzcode-io/feat/digest-cron
Browse files Browse the repository at this point in the history
feat: Cron job to gather Github info and digest them to a SQLite database
  • Loading branch information
souhaib-benbouzid authored Sep 9, 2024
2 parents 2aba3ee + ff443bd commit 042e64e
Show file tree
Hide file tree
Showing 165 changed files with 2,978 additions and 2,754 deletions.
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

0 comments on commit 042e64e

Please sign in to comment.