6.1) App Screen 3 (UI + Backend integration)

ALOK SHAKYA
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

  1. published_articles: is a relationship between user_details table and article table using foreign key user_id
  2. commented_on : is a relationship between user_details table and comment table using foreign key user_id
  3. liked_article: is a relationship between user_details table and article_like table using foreign key user_id
  4. 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

  1. rec.published_articles: which stores the details of all published articles and this array is passed to ng-repeat of displaying published articles.
  2. 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.
  3. 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.

Previous Next

--

--