MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / getGithubURL

Function getGithubURL

services/githubService.js:51–84  ·  view source on GitHub ↗
(searchParams, resultsOptions = {}, searchString)

Source from the content-addressed store, hash-verified

49 * @param resultsOptions {Object} - Ordering and pagination of results
50 */
51const getGithubURL = (searchParams, resultsOptions = {}, searchString) => {
52 const baseURL = config.get("githubApi.baseUrl");
53 const issuesAndPRsPath = "/search/issues";
54
55 const urlObj = new URL(baseURL);
56 urlObj.pathname = issuesAndPRsPath;
57
58 const defaultParams = {
59 org: config.get("githubApi.org"),
60 };
61
62 const finalSearchParams = Object.assign({}, defaultParams, searchParams);
63
64 const paramsObjArr = Object.entries(finalSearchParams);
65 const paramsStrArr = paramsObjArr.map(([key, value]) => `${key}:${value}`);
66
67 // The string that can be entrered as text on Github website for simple search
68 let prsSearchText = paramsStrArr.join(" ");
69
70 if (searchString) {
71 prsSearchText = `${searchString} ${prsSearchText}`;
72 }
73
74 urlObj.searchParams.append("q", prsSearchText);
75
76 // Manipulate returned results
77 // e.g number of results, pagination, etc
78 Object.entries(resultsOptions).forEach(([key, value]) => {
79 urlObj.searchParams.append(key, value);
80 });
81
82 const createdURL = urlObj.href;
83 return createdURL;
84};
85
86/** Create the fetch object to call on github url
87 * @access private

Callers 6

fetchPRsByUserFunction · 0.85
fetchOpenPRsFunction · 0.85
fetchMergedPRsFunction · 0.85
fetchOpenIssuesFunction · 0.85
fetchClosedIssuesFunction · 0.85
fetchLastMergedPRFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected