Skip to content

Data Models

RutvikTak edited this page Mar 4, 2022 · 18 revisions

Chat

type ChatMessage struct {
    Message         string
    PhotoURL        string
    SendDate        Time.time
    Type            string
    UID             string
    User            string
}

Notification sent from either Firebase/Pusher

x? = can be null

{
   notification:{

   String?  title,
   String?  body,
   String?  image, // update image parameter as per platform to display image in notifications tray

   },
   data:{

   String?  "image" //this image field is used within app,
   String?  "interest": //interest name,
     // if it's a Chase notification then pass the chaseId to id 
   String?  "id"://chaseId
    // if sending the whole chase data, then pass it like this
   "chase":{
      "id"://chaseId
      // other chase details
     } 
   
   }
}

Notification Document schema stored for each User in this single notifications collection when any Notification is sent

{
    String interest,// interest name
    String? id,// notification doc id 
    String uid, // user unique id
    String? title,
    String? body,
    String? image,
    TimeStamp? createdAt,
    // Schema for this `data` will be same as the data schema sent in notification from firebase/pusher except the image and interest
    // can be dropped here as we already pass them above.
    Map<String, dynamic>? data,
      
}

We'll be managing addition of interests through Firebase.

{

    String id,// doc id
    String instanceId,
    String name,// interest name
    bool isCompulsory,
    DateTime createdAt,

}

Some of the ways in which it will help :

  1. No need to push update when we want to add/update/delete interest streams in our application.

How does it work?

  1. We add new interest doc in interests collection. Add required data for it.
  2. App fetches this interests.
  3. Checks if any one of them isCompulsory notification like "Chases" notifications streams and if yes then adds it to users device interests.
  4. User sees all of the notifications streams from his interests in the NotificationsView.
  5. In the settings, user can enable/disable notification streams from interests which are not compulsory.

Notifications Handling

  1. Chases notifications take the user to chase details view.
  2. All other notifications show user a Dialog with notification title, body, image.

Notifications

type Notification struct {
	Name		string
	Desc            string
	ImageURL	string
	URL		string
}

Chase Model

type Tags struct {
	Name		[]string
}

type Networks struct {
	Name		string
	URL         string
	Tier		int
	Logo		string
	Other		string
}

type Wheels struct {
	W1  string
	W2  string
	W3  string
	W4  string
}

type Sentiment struct {
	Magnitude	float64		`firestore:"magnitude"`
	Score		float64		`firestore:"score"`
}

type Chase struct {
	ID          string    	""
	Name        string    	`firestore:"Name"`
	Desc        string    	`firestore:"Desc"`
	Live        bool      	`firestore:"Live"`
	Networks	[]Networks	`firestore:"Networks"`
	Wheels      Wheels      `firestore:"Wheels"`
	Votes       int       	`firestore:"Votes"`
	CreatedAt   time.Time 	`firestore:"CreatedAt"`
	EndedAt     time.Time 	`firestore:"EndedAt"`
	ImageURL    string      `firestore:"ImageURL"`
	Reddit		string		`firestore:"Reddit"`
	Sentiment	Sentiment
	Tags		Tags
}

Push Tokens

type PushTokens struct {
	Token		string		`json:"token"`
	CreatedAt	time.Time	`json:"created_at"`
	TokenType	string		`json:"type"`
}

User Model

type User struct {
	UID 		string			`firestore:"uid"`
	LastUpdated	time.Time		`firestore:"lastupdated"`
	PhotoURL	string			`firestore:"photourl"`
	UserName	string			`firestore:"username"`
	Tokens		[]PushTokens	`firestore:"tokens"`
}
Clone this wiki locally