Skip to content

Commit

Permalink
Create an API to aggregate usage logs (#858)
Browse files Browse the repository at this point in the history
This is a simple API to invoke the lambda
#857 via API Gateway. This is
done on the server side (AWS lambda)

### Testing

Here is the sneak peak of the detail page which calls this API:

![Screen Shot 2022-10-11 at 16 36
03](https://user-images.githubusercontent.com/475357/195217369-c8a2e03f-27c6-4ad7-b1cf-a865ca8c2565.png)
  • Loading branch information
huydhn authored Oct 21, 2022
1 parent 322195a commit f6c460d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions torchci/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface PRData {
title: string;
shas: { sha: string; title: string }[];
}

export interface FlakyTestData {
file: string;
suite: string;
Expand Down
1 change: 1 addition & 0 deletions torchci/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"recharts": "^2.1.10",
"shlex": "^2.1.0",
"swr": "^1.3.0",
"typed-rest-client": "^1.8.9",
"urllib": "^2.38.0",
"uuid": "^8.3.2"
},
Expand Down
14 changes: 14 additions & 0 deletions torchci/pages/api/usage-log-aggregator/lambda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as restc from "typed-rest-client/RestClient";
import { NextApiRequest, NextApiResponse } from "next";

// TODO: Create a hostname and secure this API
const USAGE_LOG_AGGREGATOR_API = "https://0y7izelft6.execute-api.us-east-1.amazonaws.com/default/usage-log-aggregator"

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const client = new restc.RestClient(null);
const response = await client.create(USAGE_LOG_AGGREGATOR_API, JSON.parse(req.query.params as string));
res.status(response.statusCode).json(response.result);
}
26 changes: 26 additions & 0 deletions torchci/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7742,6 +7742,13 @@ [email protected], qs@^6.4.0:
dependencies:
side-channel "^1.0.4"

qs@^6.9.1:
version "6.11.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==
dependencies:
side-channel "^1.0.4"

[email protected]:
version "0.2.0"
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
Expand Down Expand Up @@ -8672,6 +8679,11 @@ tsutils@^3.21.0:
dependencies:
tslib "^1.8.1"

[email protected]:
version "0.0.6"
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
Expand Down Expand Up @@ -8714,6 +8726,15 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"

typed-rest-client@^1.8.9:
version "1.8.9"
resolved "https://registry.yarnpkg.com/typed-rest-client/-/typed-rest-client-1.8.9.tgz#e560226bcadfe71b0fb5c416b587f8da3b8f92d8"
integrity sha512-uSmjE38B80wjL85UFX3sTYEUlvZ1JgCRhsWj/fJ4rZ0FqDUFoIuodtiVeE+cUqiVTOKPdKrp/sdftD15MDek6g==
dependencies:
qs "^6.9.1"
tunnel "0.0.6"
underscore "^1.12.1"

typedarray-to-buffer@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
Expand Down Expand Up @@ -8751,6 +8772,11 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

underscore@^1.12.1:
version "1.13.6"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441"
integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==

unescape@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unescape/-/unescape-1.0.1.tgz#956e430f61cad8a4d57d82c518f5e6cc5d0dda96"
Expand Down

1 comment on commit f6c460d

@vercel
Copy link

@vercel vercel bot commented on f6c460d Oct 21, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.