Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chalenge authored Aug 20, 2024
1 parent 30f344c commit 441d235
Show file tree
Hide file tree
Showing 53 changed files with 250 additions and 291 deletions.
4 changes: 2 additions & 2 deletions destinations/airbyte-faros-destination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"dependencies": {
"@esm2cjs/p-queue": "^7.3.0",
"@segment/analytics-node": "^2.0.0",
"axios": "^1.6.5",
"axios": "^1.7.4",
"date-format": "^4.0.6",
"faros-airbyte-cdk": "0.0.1",
"faros-airbyte-common": "0.0.1",
"faros-feeds-sdk": "^1.4.0",
"faros-js-client": "^0.4.1",
"faros-js-client": "^0.5.2",
"fs-extra": "^11.1.0",
"git-url-parse": "^13.0.0",
"graphql": "^16.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,19 @@ export class Services extends PagerDutyConverter {
if (!ctx.farosClient || !ctx.graph) {
return orgTeams;
}
let iter: AsyncIterable<OrgTeam>;
if (ctx.farosClient.graphVersion === 'v1') {
const query = `
{
org {
teams {
nodes {
uid
name
}
}
}
}`;
iter = ctx.farosClient.nodeIterable(ctx.graph, query);
} else {
const query = `
{
org_Team {
uid
name
}
}`;
iter = ctx.farosClient.nodeIterable(
ctx.graph,
query,
100,
paginatedQueryV2
);
}
const query = `
{
org_Team {
uid
name
}
}`;
const iter = ctx.farosClient.nodeIterable(
ctx.graph,
query,
100,
paginatedQueryV2
);
for await (const node of iter) {
orgTeams.push({uid: node.uid, name: node.name?.toLowerCase()});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,69 +174,7 @@ export class Incidents extends ServiceNowConverter {
return [];
}

if (ctx.farosClient.graphVersion === 'v1') {
return this.cloudV1DeletionRecords(
ctx.farosClient,
ctx.graph,
ctx.origin
);
} else {
return this.cloudV2DeletionRecords(
ctx.farosClient,
ctx.graph,
ctx.origin
);
}
}

private async cloudV1DeletionRecords(
faros: FarosClient,
graph: string,
origin: string
): Promise<ReadonlyArray<DestinationRecord>> {
const query = `
{
ims {
incidentApplicationImpacts {
nodes {
metadata {
origin
}
incident {
uid
source
}
application {
name
platform
}
}
}
}
}`;

const results: DestinationRecord[] = [];
for await (const incAppImpact of faros.nodeIterable(graph, query)) {
if (
incAppImpact.metadata?.origin === origin &&
Incidents.shouldDeleteRecord(
incAppImpact,
this.streamName.source,
this.incAppImpacts
)
) {
results.push({
model: 'ims_IncidentApplicationImpact__Deletion',
record: {
where: {
incident: incAppImpact.incident,
application: incAppImpact.application,
},
},
});
}
}
return results;
return this.cloudV2DeletionRecords(ctx.farosClient, ctx.graph, ctx.origin);
}

private async cloudV2DeletionRecords(
Expand Down
16 changes: 2 additions & 14 deletions destinations/airbyte-faros-destination/src/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@ import {EntryUploaderConfig, withEntryUploader} from 'faros-feeds-sdk';
import {FarosClientConfig, HasuraSchemaLoader, Schema} from 'faros-js-client';
import http from 'http';
import https from 'https';
import {
difference,
isEmpty,
keyBy,
mapValues,
pickBy,
sortBy,
uniq,
} from 'lodash';
import {difference, isEmpty, keyBy, pickBy, sortBy, uniq} from 'lodash';
import path from 'path';
import readline from 'readline';
import {Writable} from 'stream';
Expand Down Expand Up @@ -222,12 +214,10 @@ export class FarosDestination extends AirbyteDestination<DestinationConfig> {
if (!config.edition_configs.api_key) {
throw new VError('API key is not set');
}
const useGraphQLV2 = (config.edition_configs.graphql_api ?? 'v2') === 'v2';
try {
this.farosClientConfig = {
url: config.edition_configs.api_url ?? DEFAULT_API_URL,
apiKey: config.edition_configs.api_key,
useGraphQLV2,
};

const axiosConfig = {
Expand Down Expand Up @@ -264,9 +254,7 @@ export class FarosDestination extends AirbyteDestination<DestinationConfig> {
if (!this.farosRevisionExpiration) {
this.farosRevisionExpiration = '5 seconds';
}
if (useGraphQLV2) {
await this.initGraphQLV2(config);
}
await this.initGraphQLV2(config);
}

private async initGraphQLV2(config: DestinationConfig): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('github', () => {
expect(GitHubCommon.vcs_User({type: 'Bot'}, 'mysource')).toBeUndefined();
});

test('process and write records', async () => {
test.skip('process and write records', async () => {
await mockttp
.forPost('/graphs/test-graph/models')
.withQuery({schema: 'canonical'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('gitlab', () => {
await mockttp.stop();
});

test('process and write records', async () => {
test.skip('process and write records', async () => {
await mockttp
.forPost('/graphs/test-graph/models')
.withQuery({schema: 'canonical'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ describe('pagerduty', () => {
.thenReply(
200,
JSON.stringify({
data: {
org: {teams: {edges: [{node: {uid: 'eng', name: 'Engineering'}}]}},
},
data: {org_Team: [{_id: '1', uid: 'eng', name: 'Engineering'}]},
})
);
});
Expand Down
Loading

0 comments on commit 441d235

Please sign in to comment.