-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: add table backed skin module"
This reverts commit 376cde0.
- Loading branch information
Showing
4 changed files
with
11 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,13 @@ | ||
import { capture } from '@snapshot-labs/snapshot-sentry'; | ||
import log from '../../helpers/log'; | ||
import db from '../../helpers/mysql'; | ||
import { buildWhereQuery, checkLimits } from '../helpers'; | ||
import { spaces } from '../../helpers/spaces'; | ||
|
||
const COLORS = ['bg', 'link', 'text', 'border', 'heading', 'primary']; | ||
|
||
function formatSkins(queryResults) { | ||
return queryResults.map(skin => { | ||
skin.colors = Object.fromEntries( | ||
COLORS.map(color => [color, `#${skin[color]}`]) | ||
); | ||
return skin; | ||
export default function () { | ||
const skins = {}; | ||
Object.values(spaces).forEach((space: any) => { | ||
if (space.skin) | ||
skins[space.skin] = skins[space.skin] ? skins[space.skin] + 1 : 1; | ||
}); | ||
} | ||
|
||
export default async function (parent, args) { | ||
const { first, skip, where = {} } = args; | ||
|
||
checkLimits(args, 'skins'); | ||
|
||
const fields = { | ||
id: 'string' | ||
}; | ||
const whereQuery = buildWhereQuery(fields, 's', where); | ||
const queryStr = whereQuery.query; | ||
const params: any[] = whereQuery.params; | ||
|
||
const query = ` | ||
SELECT s.* FROM skins s | ||
WHERE id IS NOT NULL ${queryStr} | ||
ORDER BY id ASC LIMIT ?, ? | ||
`; | ||
params.push(skip, first); | ||
|
||
try { | ||
return formatSkins(await db.queryAsync(query, params)); | ||
} catch (e: any) { | ||
log.error(`[graphql] skins, ${JSON.stringify(e)}`); | ||
capture(e, { args }); | ||
return Promise.reject(new Error('request failed')); | ||
} | ||
return Object.entries(skins).map(skin => ({ | ||
id: skin[0], | ||
spacesCount: skin[1] | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters