Skip to content

Commit

Permalink
📖 DOC: comments on Supabase entities
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Sulzer <[email protected]>
  • Loading branch information
violoncelloCH authored and alejandrocalles committed Jun 2, 2024
1 parent a92fd4f commit ae72966
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import com.github.swent.echo.data.model.AssociationHeader
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// This annotated helper class is needed for the serialization of the double join queries to work
/**
* Annotated helper class for the Supabase double join queries to work.
*
* @property association AssociationHeader instance.
*/
@Serializable
data class AssociationHelper(@SerialName("associations") val association: AssociationHeader)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ package com.github.swent.echo.data.supabase.entities
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// This annotated helper class is needed for the serialization of the double join queries to work
/**
* Annotated helper class representing an association subscription relation in Supabase. Needed for
* the serialization of the double join queries.
*
* @property userId unique id of the user subscribed to the association
* @property associationId unique id of the association the user is subscribed to
*/
@Serializable
data class AssociationSubscriptionSupabase(
@SerialName("user_id") val userId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import com.github.swent.echo.data.model.Association
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Annotated version of the Association data class. Used for supabase queries.
*
* @property associationId the unique id of the association
* @property name the name of the association
* @property description the descirbtion of the association
* @property url the url to a website or social media account of the association
* @property relatedTags a list of TagHelpers enclosing the tags related to the association
*/
@Serializable
data class AssociationSupabase(
@SerialName("association_id") val associationId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package com.github.swent.echo.data.supabase.entities

import kotlinx.serialization.SerialName

/**
* Annotated helper class representing an tag assignment to an association relation in Supabase.
* Needed for the serialization of the double join queries.
*
* @property tagId unique id of the tag assigned to the association
* @property associationId unique id of the association to which the tag is linked to
*/
data class AssociationTagSupabase(
@SerialName("tag_id") val tagId: String,
@SerialName("association_id") val associationId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package com.github.swent.echo.data.supabase.entities
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Annotated helper class representing an event join relation in Supabase. Needed for the
* serialization of the double join queries.
*
* @property userId unique id of the user subscribed to the event
* @property eventId unique id of the event the user is subscribed to
*/
@Serializable
data class EventJoinSupabase(
@SerialName("user_id") val userId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ import java.time.ZonedDateTime
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Serializable version of the Event data class. Used to retrieve events from Supabase.
*
* @property eventId the unique id of the event
* @property creator the creator of the event
* @property organizer the association organizing the event, if null the organizer is the event
* creator
* @property title the title of the event
* @property description the description of the event
* @property locationName the name of the location of the event
* @property locationLat lat coords of the location of the event
* @property locationLong long coords of the location of the event
* @property startDate the start date of the event
* @property endDate the end date of the event
* @property tags the tags related to the event
* @property participantCount the number of participants of the event
* @property maxParticipants the maximum number of participant of the event
* @property imageId the picture reference of the event
*/
@Serializable
data class EventSupabase(
@SerialName("event_id") val eventId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@ import com.github.swent.echo.data.model.Event
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Serializable version of the Event data class. Used to store events in Supabase.
*
* @property eventId the unique id of the event
* @property creatorId the id of the creator of the event
* @property organizerId the id of the association organizing the event, if null the organizer is
* the event creator
* @property title the title of the event
* @property description the description of the event
* @property locationName the name of the location of the event
* @property locationLat lat coords of the location of the event
* @property locationLong long coords of the location of the event
* @property startDate the start date of the event
* @property endDate the end date of the event
* @property participantCount the number of participants of the event
* @property maxParticipants the maximum number of participant of the event
* @property imageId the picture reference of the event
*/
@Serializable
data class EventSupabaseSetter(

// having the default value set to null here is needed so that the serializer
// completely ignores the attribute on insertion when we want supabase to generate the
// completely ignores the attribute on insertion when we want Supabase to generate the
// uuid eventId
@SerialName("event_id") val eventId: String? = null,
@SerialName("creator_id") val creatorId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package com.github.swent.echo.data.supabase.entities
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Annotated helper class representing a tag added to an event relation in Supabase. Needed for the
* serialization of the double join queries.
*
* @property tagId unique id of the tag assigned to the event
* @property eventId unique id of the event the tag is assigned to
*/
@Serializable
data class EventTagSupabase(
@SerialName("tag_id") val tagId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import com.github.swent.echo.data.model.Tag
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// This annotated helper class is needed for the serialization of the double join queries to work
/**
* Annotated helper class for the Supabase double join queries to work.
*
* @property tag Tag instance.
*/
@Serializable data class TagHelper(@SerialName("tags") val tag: Tag)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import com.github.swent.echo.data.supabase.serializer.SemesterSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Serializable version of the UserProfile data class. Used to retrieve user profiles from Supabase.
*
* @property userId the unique id of the user
* @property name the name of the user
* @property semester the semester of the user
* @property section the section of the user
* @property tags the list of TagHelper embedding tags related to the user
* @property committeeMember the list of associations where the user is a committee member of
* @property associationsSubscriptions the list of association subscriptions of the user
*/
@Serializable
data class UserProfileSupabase(
@SerialName("user_id") val userId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import com.github.swent.echo.data.supabase.serializer.SemesterSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Serializable version of the UserProfile data class. Used to store user profiles in Supabase.
*
* @property userId the unique id of the user
* @property name the name of the user
* @property semester the semester of the user
* @property section the section of the user
*/
@Serializable
data class UserProfileSupabaseSetter(
@SerialName("user_id") val userId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package com.github.swent.echo.data.supabase.entities
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Annotated helper class representing a tag added to a user relation in Supabase. Needed for the
* serialization of the double join queries.
*
* @property userId unique id of the user
* @property tagId unique id of the tag
*/
@Serializable
data class UserTagSupabase(
@SerialName("user_id") val userId: String,
Expand Down

0 comments on commit ae72966

Please sign in to comment.