6.1) App Screen 3 (UI + Backend integration)
3 min readAug 6, 2017
In this integration I have made a RecentActivityController and recentActivity.html view to perform my actions
Here is the code snippet for both of them
1: RecentActivityController.js
2. recentActivity.html
In database I am making query using relationships to fetch all details associated to a particular user
var query=
{
"type":"select",
"args":{
"table":"user_details",
"columns":
[
{
"name":"published_articles",
"columns":[
"article_id","title","created"
],
"order_by":"-created"
},
{
"name":"commented_on",
"columns":[
"content","created",
{
"name":"commented_on_article",
"columns":["title","article_id"]
}
],
"order_by":"-created"
},
{
"name":"liked_article",
"columns":[
{
"name":"liked_on_article",
"columns":
[
"article_id","title","created"
]
}
],
"order_by":"-liked_on_article.created"
}
],
"where":{"user_id":$scope.rec.user_id}
}
};
In this query I am using 4 relationships
- published_articles: is a relationship between user_details table and article table using foreign key user_id
- commented_on : is a relationship between user_details table and comment table using foreign key user_id
- liked_article: is a relationship between user_details table and article_like table using foreign key user_id
- liked_on_article : is a relationship between article_like table and article table using foreign key article_id
In this way I get all information of a particular using this query. Then inside controller I have defined three arrays
- rec.published_articles: which stores the details of all published articles and this array is passed to ng-repeat of displaying published articles.
- rec.commented_on: which stores the information of all comments on which user has commented and this array is passed to ng-repeat of displaying of comment information.
- rec.liked_article: which stores the information of all the likes on which user has liked and this array is passed to ng-repeat of displaying of liked articles.
Here are some screen shots:
In this way I made all functionalities of my app working.
In next week blog I would display user feedback.
Thanks for reading.