Skip to content

Commit

Permalink
Revert "feat: add table backed skin module"
Browse files Browse the repository at this point in the history
This reverts commit 376cde0.
  • Loading branch information
wa0x6e committed Jan 9, 2025
1 parent 376cde0 commit b69bd54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 79 deletions.
2 changes: 0 additions & 2 deletions src/graphql/operations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import proposal from './proposal';
import proposals from './proposals';
import ranking from './ranking';
import roles from './roles';
import skin from './skin';
import skins from './skins';
import space from './space';
import spaces from './spaces';
Expand All @@ -36,7 +35,6 @@ export default {
aliases,
follows,
subscriptions,
skin,
skins,
networks,
options,
Expand Down
11 changes: 0 additions & 11 deletions src/graphql/operations/skin.ts

This file was deleted.

50 changes: 10 additions & 40 deletions src/graphql/operations/skins.ts
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]
}));
}
27 changes: 1 addition & 26 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,7 @@ type Query {

statement(id: String!): Statement


skin(id: String!): Skin

skins(
first: Int! = 20
skip: Int! = 0,
where: SkinWhere
): [Skin]
skins: [Item]

networks: [Item]

Expand Down Expand Up @@ -386,10 +379,6 @@ input LeaderboardsWhere {
vote_count_lte: [Int]
}

input SkinWhere {
id: String
}

enum OrderDirection {
asc
desc
Expand Down Expand Up @@ -662,17 +651,3 @@ type Option {
name: String
value: String
}

type SkinColors {
bg: String
link: String
text: String
border: String
heading: String
primary: String
}

type Skin {
id: String!
colors: SkinColors
}

0 comments on commit b69bd54

Please sign in to comment.