-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: github users table #208
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
Open
bjohansebas
wants to merge
9
commits into
OpenPathfinder:main
Choose a base branch
from
bjohansebas:github_users
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
31cc528
feat: github users table
bjohansebas 78b45de
feat: add github_organization_members
bjohansebas 2931879
feat: implement fetchOrgMembersByLogin function
bjohansebas 735e585
feat: add validation for GitHub organization members schema
bjohansebas 86ae7fc
feat: add upsert workflow for gitHub members
bjohansebas fa33f81
feat: update github_users migration to change github_user_id type and…
bjohansebas 114f0dc
feat: implement upsert functionality for GitHub organization members
bjohansebas 0ce51fb
feat: add upsert workflow related tests
bjohansebas 0971fdd
feat: add tests for upserting GitHub organization members
bjohansebas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,52 @@ | ||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.up = async (knex) => { | ||
| await knex.schema.createTable('github_users', (table) => { | ||
| table.increments('id').primary() // Primary key | ||
| table.string('name') | ||
| table.string('email') | ||
| table.string('login').notNullable() | ||
| table.integer('github_user_id').unique().notNullable() | ||
| table.string('node_id').notNullable() | ||
| table.string('avatar_url') | ||
| table.string('gravatar_id') | ||
| table.string('url') | ||
| table.string('html_url') | ||
| table.string('gists_url') | ||
| table.string('followers_url') | ||
| table.string('following_url') | ||
| table.string('starred_url') | ||
| table.string('subscriptions_url') | ||
| table.string('organizations_url') | ||
| table.string('repos_url') | ||
| table.string('events_url') | ||
| table.string('received_events_url') | ||
| table.string('type') | ||
| table.boolean('site_admin').notNullable() | ||
| table.string('starred_at') | ||
| table.string('user_view_type') | ||
| table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable() | ||
| table.timestamp('updated_at').defaultTo(knex.fn.now()).notNullable() | ||
| }) | ||
|
|
||
| // Add trigger to 'github_organizations' table | ||
| await knex.raw(` | ||
| CREATE TRIGGER set_updated_at_github_users | ||
| BEFORE UPDATE ON github_users | ||
| FOR EACH ROW | ||
| EXECUTE FUNCTION update_updated_at_column(); | ||
| `) | ||
| } | ||
|
|
||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.down = async (knex) => { | ||
| // Drop triggers | ||
| await knex.raw('DROP TRIGGER IF EXISTS set_updated_at_github_users ON github_users;') | ||
| // Drop table | ||
| await knex.schema.dropTableIfExists('github_users') | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
src/database/migrations/20250224210945_github_organization_members.js
This file contains hidden or 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,37 @@ | ||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.up = async (knex) => { | ||
| await knex.schema.createTable('github_organization_members', (table) => { | ||
| table.increments('id').primary() // Primary key | ||
| // Foreign key to 'github_organizations' table | ||
| table | ||
| .integer('github_organization_id') | ||
| .notNullable() | ||
| .unsigned() | ||
| .references('id') | ||
| .inTable('github_organizations') | ||
| .onDelete('CASCADE') // Deletes repository if the organization is deleted | ||
| .onUpdate('CASCADE') // Updates repository if the organization ID is updated | ||
|
|
||
| // Foreign key to 'github_organizations' table | ||
| table | ||
| .integer('github_user_id') | ||
| .notNullable() | ||
| .unsigned() | ||
| .references('id') | ||
| .inTable('github_users') | ||
| .onDelete('CASCADE') // Deletes repository if the organization is deleted | ||
| .onUpdate('CASCADE') // Updates repository if the organization ID is updated | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.down = async (knex) => { | ||
| // Drop table | ||
| await knex.schema.dropTableIfExists('github_organization_members') | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This table is being created with the response from https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#list-organization-members, I think it makes the most sense. I don't think we need all the user information.