parent
48b1252ef9
commit
1256c4bb8b
|
@ -2,13 +2,14 @@ CREATE OR REPLACE FUNCTION get_requests()
|
|||
RETURNS TABLE (
|
||||
url varchar,
|
||||
requester varchar,
|
||||
imageUrl varchar,
|
||||
state varchar,
|
||||
score int,
|
||||
reqTimestamp timestamptz
|
||||
)
|
||||
LANGUAGE SQL
|
||||
AS $$
|
||||
SELECT url,displayName AS requester,state,score,reqTimestamp FROM requests
|
||||
SELECT url,displayName AS requester,imageUrl,state,score,reqTimestamp FROM requests
|
||||
JOIN scores USING (url)
|
||||
JOIN users ON requests.requester = users.userid
|
||||
WHERE state IN (SELECT state FROM states WHERE active)
|
||||
|
@ -19,13 +20,14 @@ CREATE OR REPLACE FUNCTION get_requests_all()
|
|||
RETURNS TABLE (
|
||||
url varchar,
|
||||
requester varchar,
|
||||
imageUrl varchar,
|
||||
state varchar,
|
||||
score int,
|
||||
reqTimestamp timestamptz
|
||||
)
|
||||
LANGUAGE SQL
|
||||
AS $$
|
||||
SELECT url,displayName AS requester,state,score,reqTimestamp FROM requests
|
||||
SELECT url,displayName AS requester,imageUrl,state,score,reqTimestamp FROM requests
|
||||
JOIN scores USING (url)
|
||||
JOIN users ON requests.requester = users.userid
|
||||
ORDER BY score DESC, reqTimestamp ASC;
|
||||
|
@ -35,6 +37,7 @@ CREATE OR REPLACE FUNCTION get_requests_voted(votinguserid int)
|
|||
RETURNS TABLE (
|
||||
url varchar,
|
||||
requester varchar,
|
||||
imageUrl varchar,
|
||||
state varchar,
|
||||
score int,
|
||||
reqTimestamp timestamptz,
|
||||
|
@ -42,7 +45,7 @@ CREATE OR REPLACE FUNCTION get_requests_voted(votinguserid int)
|
|||
)
|
||||
LANGUAGE SQL
|
||||
AS $$
|
||||
SELECT url,displayName AS requester,state,score,reqTimestamp,
|
||||
SELECT url,displayName AS requester,imageUrl,state,score,reqTimestamp,
|
||||
(CASE WHEN votes.userid IS NULL THEN FALSE ELSE TRUE END) AS voted
|
||||
FROM requests
|
||||
JOIN scores USING (url)
|
||||
|
@ -56,6 +59,7 @@ CREATE OR REPLACE FUNCTION get_requests_all_voted(votinguserid int)
|
|||
RETURNS TABLE (
|
||||
url varchar,
|
||||
requester varchar,
|
||||
imageUrl varchar,
|
||||
state varchar,
|
||||
score int,
|
||||
reqTimestamp timestamptz,
|
||||
|
@ -63,7 +67,7 @@ CREATE OR REPLACE FUNCTION get_requests_all_voted(votinguserid int)
|
|||
)
|
||||
LANGUAGE SQL
|
||||
AS $$
|
||||
SELECT url,displayName AS requester,state,score,reqTimestamp,
|
||||
SELECT url,displayName AS requester,imageUrl,state,score,reqTimestamp,
|
||||
(CASE WHEN votes.userid IS NULL THEN FALSE ELSE TRUE END) AS voted
|
||||
FROM requests
|
||||
JOIN scores USING (url)
|
||||
|
|
|
@ -19,8 +19,9 @@ function buildTable(requests,allRequests) {
|
|||
if (window.loggedIn) requestsDivHTML += `<th class="request-vote">Vote</td>`;
|
||||
requestsDivHTML += "</tr>";
|
||||
for (request of requests) {
|
||||
console.log(request);
|
||||
requestsDivHTML += `<tr><td class="request-url"><a href="${request.url}" target="_blank">${request.url}</a></td>\
|
||||
<td class="request-requester">${request.requester}</td>\
|
||||
<td class="request-requester"><img src="${request.imageurl}" class="table-userpic"/>${request.requester}</td>\
|
||||
<td class="request-score">${request.score}</td>`;
|
||||
if (allRequests) requestsDivHTML += `<td class="request-state">${request.state}</td>`;
|
||||
if (window.loggedIn) {
|
||||
|
|
|
@ -146,3 +146,9 @@ div#nav-userpic {
|
|||
.request-vote > button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-userpic {
|
||||
height: 32px;
|
||||
margin-top: -3px;
|
||||
margin-bottom: -7px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue