therealsujitk / android-vtop-chennai

An android application for the students of VIT Chennai.
http://vtopchennai.therealsuji.tk
GNU General Public License v3.0
149 stars 29 forks source link

Display faculty cabin details #87

Open ezhil56x opened 1 year ago

ezhil56x commented 1 year ago

Feature Request

Is your feature request related to a problem? Please describe. Currently there is no option to view a particular faculty's cabin location

Describe the solution you'd like My idea is to implement a search function to find the faculty's cabin location which includes cabin number, floor, block

therealsujitk commented 1 year ago

It's not a good idea to hard code this data into the app, we'll need a separate project to hold this data and offer it via an API which can then be fetched by this application.

ezhil56x commented 1 year ago

Hi @therealsujitk, I am interested to work on this. Can you assign me ?

Can we host the json file in GitHub itself and query each time when the student searches for a faculty's cabin. I thought of using Firebase but the cloud functions in Firebase is not included in free plan

therealsujitk commented 1 year ago

Can we host the json file in GitHub itself and query each time when the student searches for a faculty's cabin. I thought of using Firebase but the cloud functions in Firebase is not included in free plan

Doing something like that is a violation of GitHub's terms of service and will be taken down eventually. Besides, we'll need the API to handle the search queries which cannot be done on GitHub. You can try other services such as Vercel or Netlify.

ezhil56x commented 1 year ago

Ok bro, I will try out vercel or netlify and get back to you when the API part is ready. I will add authentication to update or delete the content. Is authentication required for GET also or not needed?

therealsujitk commented 1 year ago

Not required for GET requests.

ezhil56x commented 1 year ago

@therealsujitk I have completed the API part

/api/facultycabin - faculty cabin details of all faculty /api/facultycabin?n=1000 - faculty cabin details of faculty with empid 1000 /api/facultycabin?n=sa - faculty cabin details of faculties whose name contains sa in their name

This is the project structure

- faculty-cabin-api/
  - app.js
  - data.json
  - node_modules/
  - package-lock.json
  - package.json

I have planned to host the API in https://cyclic.sh which supports upto 10,000 API requests/month.

I have also added support to add, update and delete entry through various request methods with authentication. But most of the hosting platforms have read only file system, so I could not write back to data.json. If there is any work around for that I will setup workflow which gets the updated data from the API endpoint and adds it to data.json which is in the Github repository.

therealsujitk commented 1 year ago

You can also use a database like MongoDB to store your data, that would fix your write problem. The app will only use the GET requests, I assume you want to use the POST requests for another application, if you proceed with the workflow idea updating a single record can take up-to 2 minutes (maybe more) and you cannot update any other record during that time.

ezhil56x commented 1 year ago

@therealsujitk I have recreated the API and now it is using MongoDB so that add, update and delete everything works fine. I have planned to add Faculty Cabin under Staff in Profile section

/api/faculty/search?search=1000- faculty cabin details of faculty with empid 1000 /api/faculty/search?search=sa - faculty cabin details of faculties whose name contains sa in their name

Can you give a short description on how can I implement this API on the app. I have attached a rough design of the UI I have planned. Comment your thoughts!

UI

therealsujitk commented 1 year ago

The UI will have to be similar to the Receipts fragment but with a search bar on top, this search bar should not have a button, we'll have to throttle requests as the user types. Can you give an example of what the api response looks like and what information about a faculty it returns.

The API will have to be implemented similar to how it's done for Moodle - MoodleApi.java. This task can be challenging so if you want I can work on integrating it with the app.

ezhil56x commented 1 year ago

@therealsujitk Currently the API is live on https://android-vtop-chennai-api.cyclic.app/

/ - success message to check whether the API is working or not /api/faculty - faculty cabin details of all faculties /api/faculty/search?search=1000 - faculty cabin details of faculty with empid 1000 /api/faculty/search?=search=asa - faculty cabin details of faculty whose names contains the string asa

This is the format of the data when searched through empid or facultyname

{
    "faculty": {
        "empid": "1000",
        "facultyname": "Test",
        "dept": "Test",
        "cabinlocation": "This is a test data",
        "_id": "648b68620130066aadbb77cc",
        "created_at": "2023-06-15T19:37:06.682Z",
        "updated_at": "2023-06-15T19:37:06.682Z",
        "__v": 0
    }
}

This is the format when faculty data does not exist

{
    "faculty": []
}

Can you give me a description on how to integrate all of these with the current app. I am interest to give a try on this challenging task or can you take over from here and integrate with the app?

therealsujitk commented 1 year ago

Can you give me a description on how to integrate all of these with the current app. I am interest to give a try on this challenging task or can you take over from here and integrate with the app?

If you're interested in taking this up then I'll definitely guide you through it but bear in mind it'll be a very long process, otherwise I can take over from here as well. Let me know.


Lets first clean up this API.

ezhil56x commented 1 year ago

API is live on https://android-vtop-chennai-api.cyclic.app/

I have implemented the suggested changes. And I think version is not required for this simple API. page parameter is used only for api/faculty/ and not for search. Field names have been changed. node-cache have been enabled.

These are the latest endpoints of the API

/api/faculty/ - Shows details first 10 /api/faculty?page=2 - Shows details of next 10 and so on /api/faculty?search=1000 - Shows faculty cabin details of faculty with empid 1000 /api/faculty?search=asa - Shows faculty cabin details of faculty whose names contains substring asa

Format of the data when searched with name or empid

[
    {
        "empid": "1000",
        "pfix": "Test",
        "name": "Test",
        "department": "Test",
        "location": "This is a test location"
    }
]

Format of data when faculty does not exist

[]

From here I think you can takeover and integrate with the app.

therealsujitk commented 1 year ago

If possible add me as a collaborator to your repository so I can take a look at the code.

ezhil56x commented 1 year ago

I have updated the API with your suggested changes. I have invited you as collaborator. You would be getting an invite

therealsujitk commented 1 year ago

Great! One small change, instead of the response being a JSON array ([...]), change it to a JSON object ({ "faculties": [...] }). This is better in case more fields are added in future (For example the next page or whether the next page exists).

I'll work on the integration probably later this month or next month.

ezhil56x commented 1 year ago

I have updated this suggested change also. Can you give me a description how to integrate this with the app. I want to give a try on this.

therealsujitk commented 1 year ago

All of this will have to be done with similar code style to the rest of the app.