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