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/add stream teams GitHub #1112

Merged
merged 6 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {AirbyteRecord} from 'faros-airbyte-cdk';
import {toLower} from 'lodash';

import {DestinationModel, DestinationRecord} from '../converter';
import {GitHubConverter} from './common';

export class TeamMemberships extends GitHubConverter {
readonly destinationModels: ReadonlyArray<DestinationModel> = [
'vcs_TeamMembership',
'vcs_User',
];

async convert(
record: AirbyteRecord
): Promise<ReadonlyArray<DestinationRecord>> {
const source = this.streamName.source;
const membership = record.record.data;
const res: DestinationRecord[] = [];

const team = {
uid: toLower(membership.team_slug),
source,
};
const user = {
uid: toLower(membership.username),
source,
};

res.push({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to avoid writing the same entries, you can also a check similar to:

  1. https://github.com/faros-ai/airbyte-connectors/blob/main/destinations/airbyte-faros-destination/src/converters/github/workflows.ts#L29

(same for all entries you write)

model: 'vcs_User',
record: user,
});

res.push({
model: 'vcs_TeamMembership',
record: {
user,
team,
},
});

return res;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {AirbyteRecord} from 'faros-airbyte-cdk';
import {toLower} from 'lodash';

import {DestinationModel, DestinationRecord} from '../converter';
import {GitHubConverter} from './common';

export class Teams extends GitHubConverter {
readonly destinationModels: ReadonlyArray<DestinationModel> = ['vcs_Team'];

async convert(
record: AirbyteRecord
): Promise<ReadonlyArray<DestinationRecord>> {
const source = this.streamName.source;
const team = record.record.data;
const res: DestinationRecord[] = [];

res.push({
tovbinm marked this conversation as resolved.
Show resolved Hide resolved
model: 'vcs_Team',
record: {
name: team.name,
uid: toLower(team.slug),
description: team.description,
source,
},
});

return res;
}
}