From c99e22ce9929ed12fefb44874b8578875ecf0576 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Sat, 20 Jan 2024 02:09:11 +0000 Subject: [PATCH] GH Action Standards --- docs/reference/Source_Documentation.md | 17 ----------------- docs/resources/complexity-report.md | 2 +- src/controllers/getPackagesSearch.js | 5 ++++- src/controllers/getThemesSearch.js | 11 +++++------ src/database.js | 8 ++------ tests/http/getPackagesSearch.test.js | 7 +++---- 6 files changed, 15 insertions(+), 35 deletions(-) diff --git a/docs/reference/Source_Documentation.md b/docs/reference/Source_Documentation.md index acc2a9ce..6cefc903 100644 --- a/docs/reference/Source_Documentation.md +++ b/docs/reference/Source_Documentation.md @@ -667,7 +667,6 @@ with and retrieve data from the cloud hosted database instance. * [~updateDecrementStar(user, pack)](#module_database..updateDecrementStar) ⇒ object * [~getStarredPointersByUserID(userid)](#module_database..getStarredPointersByUserID) ⇒ object * [~getStarringUsersByPointer(pointer)](#module_database..getStarringUsersByPointer) ⇒ object - * [~simpleSearch(term, dir, sort, [themes])](#module_database..simpleSearch) ⇒ object * [~getUserCollectionById(ids)](#module_database..getUserCollectionById) ⇒ object * [~getSortedPackages(page, dir, method, [themes])](#module_database..getSortedPackages) ⇒ object * [~getOrderField(method, sqlStorage)](#module_database..getOrderField) ⇒ object \| null @@ -1017,22 +1016,6 @@ Use the pointer of a package to collect all users that have starred it. | --- | --- | --- | | pointer | string | The ID of the package. | - - -### database~simpleSearch(term, dir, sort, [themes]) ⇒ object -The current Fuzzy-Finder implementation of search. Ideally eventually -will use a more advanced search method. - -**Kind**: inner method of [database](#module_database) -**Returns**: object - A server status object containing the results and the pagination object. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| term | string | | The search term. | -| dir | string | | String flag for asc/desc order. | -| sort | string | | The sort method. | -| [themes] | boolean | false | Optional Parameter to specify if this should only return themes. | - ### database~getUserCollectionById(ids) ⇒ object diff --git a/docs/resources/complexity-report.md b/docs/resources/complexity-report.md index 5a0744c9..410f21e3 100644 --- a/docs/resources/complexity-report.md +++ b/docs/resources/complexity-report.md @@ -1,4 +1,4 @@ -# Complexity report, 1/17/2024 +# Complexity report, 1/20/2024 * Mean per-function logical LOC: 14.271929824561404 * Mean per-function parameter count: 0.1324561403508772 diff --git a/src/controllers/getPackagesSearch.js b/src/controllers/getPackagesSearch.js index debdf47c..86b65cfb 100644 --- a/src/controllers/getPackagesSearch.js +++ b/src/controllers/getPackagesSearch.js @@ -91,7 +91,10 @@ module.exports = { const sso = new context.sso(); - return sso.notOk().addContent(packs).addCalls("db.getSortedPackages", packs); + return sso + .notOk() + .addContent(packs) + .addCalls("db.getSortedPackages", packs); } const newPacks = await context.utils.constructPackageObjectShort( diff --git a/src/controllers/getThemesSearch.js b/src/controllers/getThemesSearch.js index e9a24712..2c3f01d5 100644 --- a/src/controllers/getThemesSearch.js +++ b/src/controllers/getThemesSearch.js @@ -40,16 +40,15 @@ module.exports = { }, async logic(params, context) { - - const packs = await context.database.getSortedPackages( - params, - true - ); + const packs = await context.database.getSortedPackages(params, true); if (!packs.ok) { const sso = new context.sso(); - return sso.notOk().addContent(packs).addCalls("db.getSortedPackages", packs); + return sso + .notOk() + .addContent(packs) + .addCalls("db.getSortedPackages", packs); } const newPacks = await context.utils.constructPackageObjectShort( diff --git a/src/database.js b/src/database.js index c1838772..6ff5d6c3 100644 --- a/src/database.js +++ b/src/database.js @@ -1492,7 +1492,7 @@ function queryClause(opts) { const searchTerm = lcterm.replace(wordSeparators, "_"); // Replaces all word separators with '_' which matches any single character - return sqlStorage`AND p.name LIKE ${"%" + searchTerm + "%" }`; + return sqlStorage`AND p.name LIKE ${"%" + searchTerm + "%"}`; } function filterClause(opts) { @@ -1591,11 +1591,7 @@ async function getSortedPackages(opts, themes = false) { INNER JOIN versions AS v ON (p.pointer = v.package AND v.deleted IS FALSE ${queryClause(opts)} ${filterClause(opts)} - ${ - themes === true - ? filterClause({ filter: "theme" }) - : sqlStorage`` - }) + ${themes === true ? filterClause({ filter: "theme" }) : sqlStorage``}) WHERE p.name IS NOT NULL diff --git a/tests/http/getPackagesSearch.test.js b/tests/http/getPackagesSearch.test.js index 4bb48ec7..103c4a88 100644 --- a/tests/http/getPackagesSearch.test.js +++ b/tests/http/getPackagesSearch.test.js @@ -71,7 +71,7 @@ describe("Behaves as expected", () => { { hasSnippets: false, hasGrammar: true, - supportedLanguages: ["js", "ts"] + supportedLanguages: ["js", "ts"], }, "get-packages-search-test", "1.0.0" @@ -84,7 +84,7 @@ describe("Behaves as expected", () => { direction: "desc", query: "get packages search", filter: "package", - fileExtension: "js" + fileExtension: "js", }, context ); @@ -102,13 +102,12 @@ describe("Behaves as expected", () => { direction: "desc", query: "get packages search", filter: "package", - fileExtension: "sql" + fileExtension: "sql", }, context ); expect(ssoEmpty.ok).toBe(true); expect(ssoEmpty.content.length).toBe(0); - }); });