Skip to content

Individual Report of Onur Can Avci

Onur Can AVCI edited this page Jun 14, 2021 · 2 revisions

Milestone 2 - Individual Deliverable


Executive Summary

We developed an application which is Practice App for a small demo before develop Columbus application in Cmpe451 course. Our application is an good example of full stack development which consists of backend and frontend. We create three projects in github projects for management of simultaneous development. Thanks to github projects, we automatize following tasks create in issues. We wrote API using flask which is a python framework and we developed frontend of project using with React which is a populer javascript library. We also used a third party api and I used unsplash api which is open collection of high-quality photos and we wrote unit tests for every API. Finally, we dockerize our application and we deploy our app in aws servers. We have two environments which are stage and production. This is for sure to application is working well. Before deploy to production environment, we deploy to stage environment and we are testing our application. Finally, we create a pull request to master and we deploy the production server after merge development branch to master branch.

API

We implemented APIs related with Columbus project. It is a good experience for use to implement these APIs.

  • Comment: User can comment and view comments of post. This api has GET and POST request. The GET request is listing comments of post and it has a parameter which is postId. The POST request is inserting comment to comments db and it inserts username, comment, postId, date and language. It detects language with third party API and it accepts postId and username as parameter.

  • EditPost: User can edit their posts. This api has just a POST request. The POST request is update post and it has two parameter which are username and postId.

  • Follow: User can view followers, followings and follow requests and create a follow request. This api has three GET and a POST request. The first GET request is getFollowers. It accept a parameter which is username. It lists followers of user. The second GET request is getFollowings. It accepts a parameter which is username. It lists following of user. The third GET request is getFollowRequests. It accepts a parameter which is username. It lists follow requests of user. The final request which is followUser POST request. It accepts two parameter and they are username of follower and username who would like to follow.

  • Home: User can view posts of following users in the home page. This request listing posts. This api has a GET request. It accepts a parameter which is username. This api also use third party api which return random advice. It also sort posts according to date of posts.

  • Locations: User can add post to location. This api has a POST request. It accepts a parameter which is address. This api also use third party api which return longitude and latitude of address. This request insert to locations db to location name, story id latitude, longitude and related locations.

  • Profile: User can view their own profile and edit their profile. This api has GET and POST requests. The GET request is getProfile and it accepts username as a parameter. It returns user information from user database. The POST request is updateProfiel and it has accepts username as a parameter too. It updates user database.

  • Report: User can report users. This api has just a POST request. The POST request is postReport and it accepts a parameter which is user id. This api insert reports database to user id.

  • SavePost: User can save posts. This api has just a POST request. The POST request is savePost and it accepts a parameter which is user name. This api insert savedPosts of user database to post id.

  • Search: User can search with text. This api has a just GET request. The GET request is search and it accepts a parameter which is search text. This api use third party api which detects language of text is in Turkish or English.

  • Story: User can create post and view posts. This api has two GET and a POST requests. The first GET request is getStory and it accepts id as a parameter. It returns story information from posts database. The other GET request is getWeatherInfo and it has accepts id as a parameter. It uses third party api which return weather informations according to location informations of post. The POST request is createStory. It accepts data in body unlike most of the request accepts data as a query parameters. It inserts post information to posts database and update the user database.

  • ViewPost: User can view posts detail. This api has a just GET request. The GET request is viewPost and it accepts a parameter which is post id. This api use third party api which find similar tags according to post tag.

  • Likes: User can like post and view likes of post. This api has a GET and a POST request. The GET request is getLikes and it accepts post id as a parameter. It returns like informations from likes database and number of likes. The POST request is likePost and it accepts post id and username as parameters. It inserts username, post id and date of like post to like database. It also updates numberOfLikes field of posts database. I implemented this api.

APPLICATION URI:

My API URI:

I developed likes APIs. I will explain in below shortly.

  • getLikes(): I get a post id as a query parameter from user and then I controlled is there a post related with this post id. If the post is not found the posts db it throws and error like “Post is not found”.
def getLikes(postId):
    postExist = findPostFromDb(postId)
    
    if not postExist:
        abort(404, 'Post is not found')

I call a function for this which is findPostFromDb. It controls in posts db.

def findPostFromDb(postId):
    db = mongo.db
    return db.posts.find_one({'id': postId}, {'_id': False})

Then I controlled Is liked the post in before. If the post is not liked before, it throws an error liked “Post is not liked”.

userThatLikesPost = getLikesFromDb(postId)
    if not userThatLikesPost:
        abort(404, 'Post is not liked')

    postLikes = list(userThatLikesPost)
    if len(postLikes) == 0:
        abort(404, 'Post is not liked')

I called a function for this control which is getLikesFromDb. It control likes db.

def getLikesFromDb(postId):
    db = mongo.db
    return db.likes.find({'postId': postId}, {'_id': False})

Then I create a variable which is data and I add post likes informations from likes database and I add number of likes in totalCount. Finally, return the data in json format.

  data = {
        'items': postLikes,
        'totalCount': len(postLikes)
    }
    return jsonify(data)
  • getLikes(): I get a post id as a query parameter from user and then I controlled is there a post related with this post id. If the post is not found the posts db it throws and error like “Post is not found”.
def likePost(postId,username):
    postExist = findPostFromDb(postId)
    if not postExist:
        abort(404, 'Post is not found')

    userExist = findUserFromDb(username)
    if not userExist:
        abort(404, 'User is not found')
        
    likedPostData = list(likedPostInfo(postId, username))
    numberOfLikes = len(list(getLikesFromDb(postId)))


    if not len(likedPostData) == 0:
        removeLikePostFromDb(likedPostData[0])
        updatePostLikesDb(postId, numberOfLikes)
        return { "message" : "Like is reverted", "status" : 200}
    else:
        likeInstance = {
            "username": username,
            "postId": postId,
            "date": datetime.datetime.now(),
        }
        addLikePostToDb(likeInstance)
        updatePostLikesDb(postId, numberOfLikes)
        return { "message" : "Post liked successfully", "status" : 200}

CODE REVIEWS

  1. https://github.com/bounswe/2021SpringGroup7/pull/103:
  • Ata added author informations to s top of the page and I said it is redundant because GitHub keeps this informations. (I reviewed Ata’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/104:
  • It works fine so I approved this pull request directly after reviewed. (I reviewed Ata’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/123:
  • It has no typo and some error in these codes, so I approved directly again after reviewed. (I reviewed Ata’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/125:
  • Abdulkadir wants to some changes for this pull requests and after that I approved this pull requests. (I reviewed Rabia’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/127:
  • It looked fine and I didn’t have any addition or changes to this pull request. So, I approved. (I reviewed Umut’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/129:
  • We reviewed in zoom and I said to Ramazan if you don’t use commented codes, you should removed the commented lines. However, he said fixed later and he used these commented lines, so I approved. (I reviewed Ramazan’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/130:
  • Codes are fine but he missing added to milestone to his pull request. I said him in zoom and I added to milestone and Abdulkadir wants to some changes from Efe. After he fixed changes, I approved. (I reviewed Efe’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/131:
  • It has no problem and I approved directly after reviewed. (I reviewed Umut’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/132:
  • He writes very clearly, so I approved. (I reviewed Hamza’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/137:
  • He writes incorrect my birthday information. I said him to its not a problem but this is not my birthday. Its not a problem so I approved. (I reviewed Ata’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/140:
  • It looked great, so I approved. After merge I deleted branch. (I reviewed Rabia’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/144:
  • Everything is fine and it was a good example for us. So, I approved. (I reviewed Abdulkadir's and Umut’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/147:
  • There is no problem in this pull request and I approved directly after reviewed. (I reviewed Abdulkadir’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/149:
  • I approved but I add a small comment for this pull request which is you can delete redundant empty lines. (I reviewed Ramazan code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/172:
  • Ata is commented this pull request but I didn’t see any problem Rabia’s code.So I approved but after I implemented my swagger page I noticed that Ata’s review and there is a problem Rabia’s code which is type error in her .yml file and I said to groups you should check your types in swagger files. (I reviewed Rabia's code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/209:
  • It was a very small fix pull request and it was no error and I approved. (I reviewed Ata’s code)
  1. https://github.com/bounswe/2021SpringGroup7/pull/225:
  • He fixed swagger pages and it was a small changes. I approved. (I reviewed Hamza’s code)

PULL REQUESTS

  1. https://github.com/bounswe/2021SpringGroup7/pull/122:
  • Added Likes api and data inserted to likes database.
  1. https://github.com/bounswe/2021SpringGroup7/pull/142:
  • Updated practice app folder structure and documentation.
  1. https://github.com/bounswe/2021SpringGroup7/pull/155:
  • Created React Project with create-react-app and add Axios.
  1. https://github.com/bounswe/2021SpringGroup7/pull/160:
  • Added React-Router-Dom and Material UI.
  • Added layouts component which are header and footer etc. The frontend projects ready for adding new page and creating components
  1. https://github.com/bounswe/2021SpringGroup7/pull/180:
  • Refactor likes api according to best practice like seperating functions and fix some problems related with likes api
  1. https://github.com/bounswe/2021SpringGroup7/pull/193:
  • Add Get Likes Swagger Integrations
  • Add Likes Swagger Integrations
  • Fix Get Likes Api
  1. https://github.com/bounswe/2021SpringGroup7/pull/205:
  • There was a problem in this pull request so I have to close this and I opened another pull request for the same purpose which is CF-5.
  1. https://github.com/bounswe/2021SpringGroup7/pull/207:
  • Add CORS config to home api: It was a great experience for me. I tried almost 4-5 hours due to this problem
  1. https://github.com/bounswe/2021SpringGroup7/pull/211:
  • Add stories to home page
  • Add Profile Page
  • Add Other Profile Page
  • Add Create Story Feature
  • Add Like Feature
  • Add Comment Feature
  • Add View Follower Feature
  1. https://github.com/bounswe/2021SpringGroup7/pull/212:
  • We tested our application and then we merged to master and deploy the production.
  1. https://github.com/bounswe/2021SpringGroup7/pull/216:
  • Add Unit tests for likes api
  • Add freeze time package for tests
  • Add 3rd Party API
  1. https://github.com/bounswe/2021SpringGroup7/pull/219
  • Refactor likes api and like function in frontend
  • Add view number of likes
  • Fix page title
  • Add view follower user page and following user page
  • Fix Corse Problem (Abdulkadir did this issue)
  • Add express server to frontend (Abdulkadir did this issue)

ISSUES

ISSUE URL ISSUE NAME
https://github.com/bounswe/2021SpringGroup7/issues/220. Write Summary of Individual Work for Onur Can Avci
https://github.com/bounswe/2021SpringGroup7/issues/221. Write Individual Report for Onur Can Avci
https://github.com/bounswe/2021SpringGroup7/issues/215. CB-38 Bugfix/Fixing The Docker Configs For Frontend, CORS Error For Backend and Follow Action Bug
https://github.com/bounswe/2021SpringGroup7/issues/208. CF-3 Frontend Pages
https://github.com/bounswe/2021SpringGroup7/issues/206. CB-37 Fix Cors Error
https://github.com/bounswe/2021SpringGroup7/issues/190. CB-30 Add Swagger Documentation for Likes Api
https://github.com/bounswe/2021SpringGroup7/issues/156. CF-2 Routing and Material UI
https://github.com/bounswe/2021SpringGroup7/issues/151. CF-1 Creating React App
https://github.com/bounswe/2021SpringGroup7/issues/138. Upload meeting #10 notes
https://github.com/bounswe/2021SpringGroup7/issues/133. CB-12 Refactor Practice App
https://github.com/bounswe/2021SpringGroup7/issues/121. CB-31 Unit Test for Likes Api and 3rd Party Api
https://github.com/bounswe/2021SpringGroup7/issues/98. CB-1 Likes API
https://github.com/bounswe/2021SpringGroup7/issues/96. Researching and Creating GitHub Projects

OTHER

Clone this wiki locally