Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: change of data fetching method #9

Open
baron-chiu opened this issue Jan 28, 2021 · 2 comments
Open

Improvement: change of data fetching method #9

baron-chiu opened this issue Jan 28, 2021 · 2 comments

Comments

@baron-chiu
Copy link
Contributor

Currently the data is fetched by static URLs, and the results are limited by the api.

OpendataTW.url = 'https://data.ntpc.gov.tw/api/datasets/308DCD75-6434-45BC-A95F-584DA4FED251/json?size=2000';

PR #6 doesn't solve it either. It just increases the limit to 2000.

Proposal:

  1. Remove the url in opendata-tw.js. Instead, provide a Get method of the url with offset and limit.
  2. Fetch the data multiple times and asynchronously.

The fetch batch maybe determined by count in the response of the first 1000 results.
If count is more then 1000, then creates a batch of requests to fetch the remaining data and merge them with the first 1000 result.

API reference: 臺北市政府行政機關辦公日曆表

@baron-chiu baron-chiu changed the title Improve/Change of data fetching method Improvement: change of data fetching method Jan 28, 2021
@baron-chiu
Copy link
Contributor Author

It seems my javascript is very limited and I have problem implementing the chaining of all the Promises.

Does it have a better approach?

@baron-chiu
Copy link
Contributor Author

baron-chiu commented Aug 27, 2021

#10 is open to add the feature. However the date range provided by OpenData is still limited to the latest year, and the cache will expire eventually.

Should the library provide a cache update method for users to trigger manually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant