mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
First webui commit
This commit is contained in:
parent
e38f5d08ab
commit
c4611b92f8
2011 changed files with 30382 additions and 1874 deletions
|
@ -32,7 +32,7 @@ func (rt *_router) GetUserStream(w http.ResponseWriter, r *http.Request, ps http
|
|||
stream, err := rt.db.GetUserStream(uid, start_index, limit)
|
||||
|
||||
if err != nil {
|
||||
helpers.SendInternalError(err, "Database error: GetUserProfile", w, rt.baseLogger)
|
||||
helpers.SendInternalError(err, "Database error: GetUserStream", w, rt.baseLogger)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
func (db *appdbimpl) GetUserStream(uid string, start_index int, limit int) (*[]structures.Photo, error) {
|
||||
|
||||
// Get photos from the database
|
||||
rows, err := db.c.Query(`SELECT "p"."user", "p"."id", "p"."date",
|
||||
rows, err := db.c.Query(`SELECT "p"."user", "u"."name", "p"."id", "p"."date",
|
||||
(
|
||||
SELECT COUNT(*) AS "likes" FROM "likes" AS "l"
|
||||
WHERE "l"."photo_id" = "p"."id"
|
||||
|
@ -16,9 +16,17 @@ func (db *appdbimpl) GetUserStream(uid string, start_index int, limit int) (*[]s
|
|||
(
|
||||
SELECT COUNT(*) AS "comments" FROM "comments" AS "c"
|
||||
WHERE "c"."photo" = "p"."id"
|
||||
),
|
||||
(
|
||||
SELECT EXISTS (
|
||||
SELECT * FROM "likes" AS "l"
|
||||
WHERE "l"."photo_id" = "p"."id"
|
||||
AND "l"."user" = ?
|
||||
)
|
||||
)
|
||||
FROM "photos" AS "p"
|
||||
WHERE "p"."user" IN (
|
||||
FROM "photos" AS "p", "users" AS "u"
|
||||
WHERE "p"."user" = "u"."uid"
|
||||
AND "p"."user" IN (
|
||||
SELECT "followed" FROM "follows" WHERE "follower" = ?
|
||||
)
|
||||
AND "p"."user" NOT IN (
|
||||
|
@ -26,7 +34,7 @@ func (db *appdbimpl) GetUserStream(uid string, start_index int, limit int) (*[]s
|
|||
)
|
||||
ORDER BY "p"."date" DESC
|
||||
LIMIT ?
|
||||
OFFSET ?`, uid, uid, limit, start_index)
|
||||
OFFSET ?`, uid, uid, uid, limit, start_index)
|
||||
if err != nil {
|
||||
// Return the error
|
||||
return nil, err
|
||||
|
@ -39,7 +47,7 @@ func (db *appdbimpl) GetUserStream(uid string, start_index int, limit int) (*[]s
|
|||
for rows.Next() {
|
||||
// If there is a next row, we create an instance of Photo and add it to the slice
|
||||
var photo structures.Photo
|
||||
err = rows.Scan(&photo.UID, &photo.ID, &photo.Date, &photo.Likes, &photo.Comments)
|
||||
err = rows.Scan(&photo.UID, &photo.Username, &photo.ID, &photo.Date, &photo.Likes, &photo.Comments, &photo.Liked)
|
||||
if err != nil {
|
||||
// Return the error
|
||||
return nil, err
|
||||
|
|
|
@ -23,6 +23,7 @@ type Comment struct {
|
|||
|
||||
type Photo struct {
|
||||
UID string `json:"user_id"`
|
||||
Username string `json:"name"`
|
||||
ID int64 `json:"photo_id"`
|
||||
Likes int64 `json:"likes"`
|
||||
Comments int64 `json:"comments"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue