import {
setState,
getState,
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { Octokit } from "npm:@octokit/rest@19.0.5";
const MAX_ITEMS = 500;
const PAGE_SIZE = 50;
/**
* @returns A list of issues in ascending order of creation date.
*
* The maximum number of returned items is 500 and therefore you'll miss
* the issues that are older than the 500th one. Please choose your
* scheduling accordingly.
*/
type Github = {
token: string;
};
export async function main(auth: Github, owner: string, repo: string) {
const octokit = new Octokit({
auth: auth.token,
});
const newIssues: Issue[] = [];
const lastUpdate = await getState();
let runLoop = true;
let page = 1;
do {
const result = await octokit.issues.listForRepo({
owner,
repo,
filter: "all",
state: "open",
sort: "created",
direction: "desc",
per_page: PAGE_SIZE,
page: page++,
});
const issues = result.data.filter((i) => i && !i.pull_request);
for (let i = 0; i < issues.length; i++) {
const issue = issues[i];
if (new Date(issue.created_at).getTime() <= lastUpdate) {
runLoop = false;
break;
}
newIssues.push({
title: issue.title,
url: issue.html_url,
created_at: issue.created_at,
user: {
login: issue.user?.login,
url: issue.user?.html_url,
},
labels: <string[]>(
issue.labels
.map((l) => (typeof l === "string" ? l : l.name))
.filter(Boolean)
),
});
if (newIssues.length >= MAX_ITEMS) {
runLoop = false;
break;
}
}
if (result.data.length < PAGE_SIZE) {
break;
}
} while (runLoop);
if (newIssues.length) {
await setState(new Date(newIssues[0].created_at).getTime());
}
return newIssues.reverse();
}
interface Issue {
title: string;
url: string;
created_at: string;
user: {
login?: string;
url?: string;
};
labels: string[];
}
Submitted by admin 497 days ago
import { setState, getState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { Octokit } from "npm:@octokit/rest@19.0.5";
const MAX_ITEMS = 500
const PAGE_SIZE = 50
/**
* @returns A list of issues in ascending order of creation date.
*
* The maximum number of returned items is 500 and therefore you'll miss
* the issues that are older than the 500th one. Please choose your
* scheduling accordingly.
*/
type Github = {
token: string;
};
export async function main(
auth: Github,
owner: string,
repo: string
) {
const octokit = new Octokit({
auth: auth.token
});
const newIssues: Issue[] = []
const lastUpdate = await getState()
let runLoop = true
let page = 1
do {
const result = await octokit.issues.listForRepo({
owner,
repo,
filter: 'all',
state: 'open',
sort: 'created',
direction: 'desc',
per_page: PAGE_SIZE,
page: page++
})
const issues = result.data.filter(i => i && !i.pull_request)
for(let i = 0; i < issues.length; i++) {
const issue = issues[i]
if(new Date(issue.created_at).getTime() <= lastUpdate) {
runLoop = false
break
}
newIssues.push({
title: issue.title,
url: issue.html_url,
created_at: issue.created_at,
user: {
login: issue.user?.login,
url: issue.user?.html_url,
},
labels: (<string[]>issue.labels.map(l => typeof l === 'string' ? l : l.name).filter(Boolean))
})
if(newIssues.length >= MAX_ITEMS) {
runLoop = false
break
}
}
if(result.data.length < PAGE_SIZE) {
break
}
} while(runLoop)
if(newIssues.length) {
await setState(new Date(newIssues[0].created_at).getTime())
}
return newIssues.reverse()
}
interface Issue {
title: string
url: string
created_at: string
user: {
login?: string
url?: string
},
labels: string[]
}
Submitted by admin 500 days ago
import { Resource, setState, getState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { Octokit } from "npm:@octokit/rest@19.0.5";
const MAX_ITEMS = 500
const PAGE_SIZE = 50
/**
* @returns A list of issues in ascending order of creation date.
*
* The maximum number of returned items is 500 and therefore you'll miss
* the issues that are older than the 500th one. Please choose your
* scheduling accordingly.
*/
export async function main(
auth: Resource<"github">,
owner: string,
repo: string
) {
const octokit = new Octokit({
auth: auth.token
});
const newIssues: Issue[] = []
const lastUpdate = await getState()
let runLoop = true
let page = 1
do {
const result = await octokit.issues.listForRepo({
owner,
repo,
filter: 'all',
state: 'open',
sort: 'created',
direction: 'desc',
per_page: PAGE_SIZE,
page: page++
})
const issues = result.data.filter(i => i && !i.pull_request)
for(let i = 0; i < issues.length; i++) {
const issue = issues[i]
if(new Date(issue.created_at).getTime() <= lastUpdate) {
runLoop = false
break
}
newIssues.push({
title: issue.title,
url: issue.html_url,
created_at: issue.created_at,
user: {
login: issue.user?.login,
url: issue.user?.html_url,
},
labels: (<string[]>issue.labels.map(l => typeof l === 'string' ? l : l.name).filter(Boolean))
})
if(newIssues.length >= MAX_ITEMS) {
runLoop = false
break
}
}
if(result.data.length < PAGE_SIZE) {
break
}
} while(runLoop)
if(newIssues.length) {
await setState(new Date(newIssues[0].created_at).getTime())
}
return newIssues.reverse()
}
interface Issue {
title: string
url: string
created_at: string
user: {
login?: string
url?: string
},
labels: string[]
}
Submitted by adam186 628 days ago
import { Resource, setState, getState } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { Octokit } from "npm:@octokit/rest@19.0.5";
const MAX_ITEMS = 500
const PAGE_SIZE = 50
/**
* @returns A list of issues in ascending order of creation date.
*
* The maximum number of returned items is 500 and therefore you'll miss
* the issues that are older than the 500th one. Please choose your
* scheduling accordingly.
*/
export async function main(
auth: Resource<"github">,
owner: string,
repo: string
) {
const octokit = new Octokit({
auth: auth.token
});
const newIssues: Issue[] = []
const lastUpdate = await getState()
let runLoop = true
let page = 1
do {
const result = await octokit.issues.listForRepo({
owner,
repo,
filter: 'all',
state: 'open',
sort: 'created',
direction: 'desc',
per_page: PAGE_SIZE,
page: page++
})
const issues = result.data.filter(i => i && !i.pull_request)
for(let i = 0; i < issues.length; i++) {
const issue = issues[i]
if(new Date(issue.created_at).getTime() <= lastUpdate) {
runLoop = false
break
}
newIssues.push({
title: issue.title,
url: issue.html_url,
created_at: issue.created_at,
user: {
login: issue.user?.login,
url: issue.user?.html_url,
},
labels: (<string[]>issue.labels.map(l => typeof l === 'string' ? l : l.name).filter(Boolean))
})
if(newIssues.length >= MAX_ITEMS) {
runLoop = false
break
}
}
if(result.data.length < PAGE_SIZE) {
break
}
} while(runLoop)
if(newIssues.length) {
await setState(new Date(newIssues[0].created_at).getTime())
}
return newIssues.reverse()
}
interface Issue {
title: string
url: string
created_at: string
user: {
login?: string
url?: string
},
labels: string[]
}
Submitted by adam186 663 days ago
import { Resource, setState, getState } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { Octokit } from "npm:@octokit/rest@19.0.5";
const MAX_ITEMS = 500
const PAGE_SIZE = 50
/**
* @returns A list of issues in ascending order of creation date.
*
* The maximum number of returned items is 500 and therefore you'll miss
* the issues that are older than the 500th one. Please choose your
* scheduling accordingly.
*/
export async function main(
auth: Resource<"github">,
owner: string,
repo: string
) {
const octokit = new Octokit({
auth: auth.token
});
const newIssues: Issue[] = []
const lastUpdate = await getState()
let runLoop = true
let page = 1
do {
const result = await octokit.issues.listForRepo({
owner,
repo,
filter: 'all',
state: 'open',
sort: 'created',
direction: 'desc',
per_page: PAGE_SIZE,
page: page++
})
const issues = result.data.filter(i => i && !i.pull_request)
for(let i = 0; i < issues.length; i++) {
const issue = issues[i]
if(new Date(issue.created_at).getTime() <= lastUpdate) {
runLoop = false
break
}
newIssues.push({
title: issue.title,
url: issue.html_url,
created_at: issue.created_at,
user: {
login: issue.user?.login,
url: issue.user?.html_url,
},
labels: (<string[]>issue.labels.map(l => typeof l === 'string' ? l : l.name).filter(Boolean))
})
if(newIssues.length >= MAX_ITEMS) {
runLoop = false
break
}
}
if(result.data.length < PAGE_SIZE) {
break
}
} while(runLoop)
if(newIssues.length) {
await setState(new Date(newIssues[0].created_at).getTime())
}
return newIssues.reverse()
}
interface Issue {
title: string
url: string
created_at: string
user: {
login?: string
url?: string
},
labels: string[]
}
Submitted by adam186 734 days ago