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

Update labels without refresh #165

Merged
merged 15 commits into from
Aug 15, 2023

Conversation

chia-yh
Copy link
Contributor

@chia-yh chia-yh commented Jul 7, 2023

Summary:

Attempt to resolve #13

Labels are only fetched on initialization, which requires users to refresh the page in order for labels to update. Having labels update without requiring users to refresh would be ideal. The changes in this PR make it so that labels are polled and updated periodically, and also causes the Sync button to also update labels.

Currently polls label data at intervals of 5 seconds (the same POLL_INTERVAL as issues), however, as updates to labels are unlikely to occur as frequently as updates to issues, increasing the interval is probably a good idea to avoid excessive requests, as users can still use the Sync button if necessary.

Type of change:

  • ✨ New Feature/ Enhancement

Changes Made:

-label.service.ts: added periodic polling and updating of label data
-label-filter-bar.component.ts: use updated label.service.ts to support updating of label data, moved simplifiedLabel into label.service.ts
-header-component.ts: changed reload() to also fetch label data
-Handle setup/cleanup of LabelService where appropriate

Screenshots:

Periodic polling:
update_labels_poll

Sync button (polling interval adjusted to 30 seconds for demonstration purposes):
update_labels_button

Proposed Commit Message:

Update labels without needing to refresh

Labels are only fetched on initialization, requiring users to refresh
in order for labels to update.

Let's change it so labels are updated periodically, and when the Sync
button is clicked.

Checklist:

  • I have tested my changes thoroughly.
  • I have created tests for any new code files created in this PR or provided a link to a issue/PR that addresses this.
  • I have added or modified code comments to improve code readability where necessary.
  • I have updated the project's documentation as necessary.

gycgabriel
gycgabriel previously approved these changes Jul 11, 2023
Copy link
Collaborator

@gycgabriel gycgabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gycgabriel
Copy link
Collaborator

@chia-yh Thanks for your PR.

@CATcher-org/2223s2 @damithc Any thoughts on what is a good poll interval for fetching labels, or should we restrict it to a manual Sync button to minimize the number of github API requests?

Comment on lines 16 to 20
export type simplifiedLabel = {
name: string;
color: string;
};

Copy link
Collaborator

@gycgabriel gycgabriel Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For another issue/PR: This would be good to resolve why we need Label vs SimplifiedLabel, it seems redundant to have both. #82

Copy link
Contributor

@Eclipse-Dominator Eclipse-Dominator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial review

src/app/core/services/label.service.ts Outdated Show resolved Hide resolved
Comment on lines 76 to 82
this.simplifiedLabels = this.labels.map((label) => {
return {
name: label.getFormattedName(),
color: label.color
};
});
this.labelsSubject.next(this.simplifiedLabels);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point it is probably more efficient to just store getFormattedName()'s result as a property of Label instead of cloning the entire label.

We can still keep simplifiedLabel but make Label implement the type simplified label so this conversion will no longer be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I implemented the change requested here in the manner that was intended, but I made an attempt to do so, please let me know if I should make further changes

src/app/core/services/label.service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Eclipse-Dominator Eclipse-Dominator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above (sorry accidentally commented instead of request change)

@@ -4,26 +4,27 @@
export class Label {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant by

Suggested change
export class Label {
export class Label implements SimplifiedLabel {

This way Label is also a simplified label. So in service there is no need to convert the label array into simplified label array as label array is already a simplified label array.

Although we do need to rename the references to SimplifiedLabel from name to formattedName.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename SimplifiedLabel -> SimpleLabel

So it makes sense for Label to implement SimpleLabel as a more complex label

Copy link
Contributor Author

@chia-yh chia-yh Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that's a much better way of implementing SimplifiedLabel. I've made the changes as suggested in the most recent commits, and also renamed SimplifiedLabel -> SimpleLabel as mentioned.

I've also made some changes to accommodate #183 , as this PR modifies parts of the original label-filter-bar.component.ts used in that PR.

@chia-yh
Copy link
Contributor Author

chia-yh commented Jul 25, 2023

@chia-yh Thanks for your PR.

@CATcher-org/2223s2 @damithc Any thoughts on what is a good poll interval for fetching labels, or should we restrict it to a manual Sync button to minimize the number of github API requests?

I was looking through some of the other issues, and came across #117 , which brings up a good point, that WATcher users can afford to view non-updated data. As this PR already has the sync button also update the labels, which aligns with the suggestion in #117 (comment), should I change it so that the periodic polling of labels is removed, and the fetching of labels is restricted to just the sync button as mentioned in an earlier comment?

While I think having periodic polling would be good to have, in my opinion, setting it to a long enough interval to prevent too many calls to fetch data would cause it to provide little benefit to the user, as they are unlikely to run into a situation where the refresh would be timely enough to update the data as they need it, and they could just use the sync button to refresh data.

Also, since the issue concerning periodic label polling is similar to the issue brought up in #117 , should the same changes decided on here be applied to the issue polling? I think the sync button also fetches issues at the moment, so it would just be a matter of removing the polling at 5 second intervals, though the change should definitely be done in a separate PR addressing #117 directly.

@Eclipse-Dominator
Copy link
Contributor

Perhaps we can make the polling an optional toggle somewhere on the page.
This way users (who somehow want to keep the page open for a long time) can still have access to updated data. Handling it should be done in a seperate PR.

Copy link
Contributor

@Eclipse-Dominator Eclipse-Dominator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@gycgabriel gycgabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gycgabriel gycgabriel merged commit d2d5370 into CATcher-org:main Aug 15, 2023
3 checks passed
joyngjr pushed a commit to joyngjr/WATcher that referenced this pull request Aug 19, 2023
Update labels without needing to refresh

Labels are only fetched on initialization, requiring users to refresh
in order for labels to update.

Let's change it so labels are updated periodically, and when the Sync
button is clicked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue Dashboard: Update labels without needing to refresh
3 participants