Open ezhil56x opened 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.
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
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.
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?
Not required for GET
requests.
@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.
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.
@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!
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.
@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?
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.
/api/faculty/search?search
I think we can just change it to /api/faculty?search
.facultyname
I think we can just have name
since it's understood it's for faculty. Similarly cabinlocation
can be changed to just location
and dept
to department
./api/v1.0/faculty
. This way if you plan to make breaking changes in future, you can do it on a newer version and users will still be able to use the app if they haven't updated it yet (This version need not be updated if it's not going to break the current version)./faculty
route is taking a very long time to load probably because you are not limiting the data you are retrieving. Add a page
or offset
and display only 10 records at a time.node-cache
for Node.js) to cache your data to speed up requests and reduce the load on your server.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.
pfix
key, let it be a part of name
.page
parameter is required even while using search
.
[GET] /api/faculty?search=asa&page=2
If possible add me as a collaborator to your repository so I can take a look at the code.
I have updated the API with your suggested changes. I have invited you as collaborator. You would be getting an invite
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.
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.
All of this will have to be done with similar code style to the rest of the app.
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