From 058fe94fd1315113b93164f679010bc0b3c139d3 Mon Sep 17 00:00:00 2001 From: Flummi Date: Mon, 24 Jun 2024 08:41:46 +0200 Subject: [PATCH] admin the second lol --- f0ck.sql | 2 +- src/inc/routes/index.mjs | 8 +++++--- src/inc/routes/ranking.mjs | 4 ++-- views/ranking.html | 4 ++-- views/snippets/navbar.html | 2 +- views/user.html | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/f0ck.sql b/f0ck.sql index 625ca3e..819d60f 100644 --- a/f0ck.sql +++ b/f0ck.sql @@ -131,7 +131,7 @@ CREATE TABLE public."user" ( login character varying(255) NOT NULL, "user" character varying(255) NOT NULL, password character varying(167) NOT NULL, - level integer NOT NULL + admin boolean NOT NULL ); ALTER TABLE public."user" OWNER TO f0ck; diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 00f9dd3..155015e 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -14,7 +14,7 @@ export default (router, tpl) => { const user = decodeURIComponent(req.params.user); const query = await db` - select "user".user, "user".created_at, user_options.* + select "user".user, "user".admin, "user".created_at, user_options.* from user_options left join "user" on "user".id = user_options.user_id where "user".user ilike ${user} @@ -35,13 +35,15 @@ export default (router, tpl) => { user: user, mode: req.session.mode, fav: false, - session: !!req.session + session: !!req.session, + limit: 99999999 }); const favs = await f0cklib.getf0cks({ user: user, mode: req.session.mode, fav: true, - session: !!req.session + session: !!req.session, + limit: 99999999 }); const count = { diff --git a/src/inc/routes/ranking.mjs b/src/inc/routes/ranking.mjs index 4cafc46..48da3e3 100644 --- a/src/inc/routes/ranking.mjs +++ b/src/inc/routes/ranking.mjs @@ -8,13 +8,13 @@ export default (router, tpl) => { try { const list = await db` select - "user".user, + "user".user, "user".admin, coalesce("user_options".avatar, ${await lib.getDefaultAvatar()}) as avatar, count(distinct(tag_id, item_id)) as count from "tags_assign" left join "user" on "user".id = "tags_assign".user_id left join "user_options" on "user_options".user_id = "user".id - group by "user".user, "user_options".avatar + group by "user".user, "user_options".avatar, "user".admin order by count desc `; const stats = await lib.countf0cks(); diff --git a/views/ranking.html b/views/ranking.html index c8ac9f9..39bc6ad 100644 --- a/views/ranking.html +++ b/views/ranking.html @@ -11,8 +11,8 @@ @for(let i = 0; i < list.length; i++) {{ i + 1 }} - - {!! list[i].user !!} + + @if(list[i].admin)⭐ @endif{!! list[i].user !!} {{ list[i].count }} @endfor diff --git a/views/snippets/navbar.html b/views/snippets/navbar.html index 1922c3d..d3dea70 100644 --- a/views/snippets/navbar.html +++ b/views/snippets/navbar.html @@ -5,7 +5,7 @@