Edits history of script submission #251 for ' List newly added issues (github)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    import {
      setState,
      getState,
    } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 hugo697 378 days ago

  • deno
    import {
      setState,
      getState,
    } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 1011 days ago

  • deno
    import { setState, getState } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 1014 days ago

  • deno
    import { Resource, setState, getState } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 1142 days ago

  • deno
    import { Resource, setState, getState } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 1177 days ago

  • deno
    import { Resource, setState, getState } from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "npm:@octokit/[email protected]";
    
    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 1248 days ago