diff --git a/backend/main.go b/backend/main.go index eebadef..60d8079 100644 --- a/backend/main.go +++ b/backend/main.go @@ -110,7 +110,7 @@ func main() { panic(err) } - _, err = agents.NewLocationEventAgent(locationModel, eventModel, contactModel) + locationAgent, err := agents.NewLocationEventAgent(locationModel, eventModel, contactModel) if err != nil { panic(err) } @@ -134,9 +134,11 @@ func main() { return } - // log.Println("Calling locationAgent!") - // err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image) - // log.Println(err) + // TODO: this can very much be parallel + + log.Println("Calling locationAgent!") + err = locationAgent.GetLocations(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image) + log.Println(err) log.Println("Calling noteAgent!") err = noteAgent.GetNotes(image.UserID, image.ImageID, image.Image.ImageName, image.Image.Image) @@ -230,6 +232,13 @@ func main() { Data: event, }) } + + for _, note := range image.Notes { + dataTypes = append(dataTypes, DataType{ + Type: "note", + Data: note, + }) + } } jsonImages, err := json.Marshal(dataTypes) diff --git a/backend/models/user.go b/backend/models/user.go index c212e72..9c4a72a 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -37,6 +37,8 @@ type ImageWithProperties struct { Location *model.Locations Organizer *model.Contacts } + + Notes []model.Notes } func getUserIdFromImage(ctx context.Context, dbPool *sql.DB, imageId uuid.UUID) (uuid.UUID, error) { @@ -72,6 +74,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] Events.AllColumns, ImageContacts.AllColumns, Contacts.AllColumns, + ImageNotes.AllColumns, + Notes.AllColumns, ). FROM( UserImages.INNER_JOIN(Image, Image.ID.EQ(UserImages.ImageID)). @@ -84,7 +88,9 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] LEFT_JOIN(ImageEvents, ImageEvents.ImageID.EQ(UserImages.ImageID)). LEFT_JOIN(Events, Events.ID.EQ(ImageEvents.EventID)). LEFT_JOIN(ImageContacts, ImageContacts.ImageID.EQ(UserImages.ImageID)). - LEFT_JOIN(Contacts, Contacts.ID.EQ(ImageContacts.ContactID))). + LEFT_JOIN(Contacts, Contacts.ID.EQ(ImageContacts.ContactID)). + LEFT_JOIN(ImageNotes, ImageNotes.ImageID.EQ(UserImages.ImageID)). + LEFT_JOIN(Notes, Notes.ID.EQ(ImageNotes.NoteID))). WHERE(UserImages.UserID.EQ(UUID(userId))) fmt.Println(listWithPropertiesStmt.DebugSql()) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 01b2138..ee2cc90 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,6 +6,7 @@ import { SearchCardEvent } from "./components/search-card/SearchCardEvent"; import { SearchCardLocation } from "./components/search-card/SearchCardLocation"; import { UserImage, getUserImages } from "./network"; import { getCardSize } from "./utils/getCardSize"; +import { SearchCardNote } from "./components/search-card/SearchCardNote"; const getCardComponent = (item: UserImage) => { switch (item.type) { @@ -13,6 +14,8 @@ const getCardComponent = (item: UserImage) => { return ; case "event": return ; + case "note": + return ; // case "Contact": // return ; // case "Website": diff --git a/frontend/src/components/search-card/SearchCardNote.tsx b/frontend/src/components/search-card/SearchCardNote.tsx index 746dfcc..5b82097 100644 --- a/frontend/src/components/search-card/SearchCardNote.tsx +++ b/frontend/src/components/search-card/SearchCardNote.tsx @@ -1,10 +1,10 @@ import { Separator } from "@kobalte/core/separator"; import { IconNote } from "@tabler/icons-solidjs"; -import type { Note } from "../../network/types"; +import type { UserImage } from "../../network"; type Props = { - item: Note; + item: Extract; }; export const SearchCardNote = ({ item }: Props) => { @@ -13,13 +13,13 @@ export const SearchCardNote = ({ item }: Props) => { return (
-

{data.title}

+

{data.Name}

-

{data.keywords}

+

Keywords TODO

- {data.content} + {data.Content}

); diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index fb47e64..e286906 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -75,6 +75,13 @@ const eventValidator = strictObject({ Organizer: nullable(contactValidator), }); +const noteValidator = strictObject({ + ID: pipe(string(), uuid()), + Name: string(), + Description: nullable(string()), + Content: string(), +}); + const locationDataType = strictObject({ type: literal("location"), data: locationValidator, @@ -85,7 +92,16 @@ const eventDataType = strictObject({ data: eventValidator, }); -const dataTypeValidator = variant("type", [locationDataType, eventDataType]); +const noteDataType = strictObject({ + type: literal("note"), + data: noteValidator, +}); + +const dataTypeValidator = variant("type", [ + locationDataType, + eventDataType, + noteDataType, +]); const getUserImagesResponseValidator = array(dataTypeValidator); export type UserImage = InferOutput;