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

Experiment UI: add archive button #910

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

stephherbers
Copy link
Contributor

@stephherbers stephherbers commented Nov 22, 2024

Description

replace deletion with archiving
I decided to save the experiment prior to archiving since the motivation for archiving is to use it as a reference for the future so we don't want to discard those changes before archiving

User Impact

users have the ability to archive working experiment with all of it's versions from the edit page

Demo

loom (the pop up for confirming if you want to archive the experiment does not appear in the demo sorry about that)

Docs

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 87.17949% with 5 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/experiments/views/experiment.py 16.66% 5 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@stephherbers stephherbers marked this pull request as ready for review November 22, 2024 19:25
def archive_working_experiment(self):
if self.is_working_version:
if self.has_versions:
for version in self.versions.all():
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be done with a single query. Something like

from field_audit.models import AuditAction

Experiment.objects.filter(working_version=self).update(is_archived=True, audit_action=AuditAction.AUDIT)

@@ -747,6 +747,13 @@ def compare_with_latest(self):
version.compare(prev_version.version)
return version.fields_changed

def archive_working_experiment(self):
Copy link
Collaborator

@SmittieC SmittieC Nov 25, 2024

Choose a reason for hiding this comment

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

This looks like it can be done inside the existing archive method? I think it should be safe to assume that when we archive an experiment that has versions, we should archive all of its versions as well.

P.S. I see there isn't a dedicated test for the "archive" method. Might be a good time to add one ⛏️

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the logic here was that if versions could have channels then you'd want to call .archive on the versions to also archive the channels.

But since you can't attach channels to a version I don't think it's necessary to do it that way.

<a href="{% url 'experiments:delete' team.slug experiment.id %}" class="pg-button-danger" onclick="return confirm('Are you sure you want to delete this experiment? This action cannot be undone.')">
Delete
</a>
<button type="submit" class="pg-button-danger" name="action" value="save_and_archive" onclick="return confirm('Are you sure you want to archive this experiment?');">Archive</button>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should tell users here that we're going to archive all the versiosn as well. Maybe that self-explanatory? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's implied.

Copy link
Collaborator

@SmittieC SmittieC left a comment

Choose a reason for hiding this comment

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

Overall looks great. One thing I think we should address before merging though:
Users will not be able to see archived experiments, so I'm thinking that we should release the channel resources when the user archives the experiment, otherwise they will have no way of getting for instance a whatsapp channel back to use for another experiment. Basically we should delete the experiment channel instances where this experiment is linked. We tell them that this is what we're going to do beforehand of course.

Or, we could still show the archived versions in the list of experiments so that users will be able to navigate to it, then we can add a tag/pill/"some sort of indicator" to clearly show that these experiments are archived. (and we should disable editing these in this case)

def test_archive_deletes_channels(self, experiment):
experiment_channel = ExperimentChannelFactory(experiment=experiment)
experiment_version = experiment.create_new_version()
experiment_version_channel = ExperimentChannelFactory(experiment=experiment_version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We wouldn't really have version channels, since all channels will be linked to the working experiment

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 - can remove this part of the test

Copy link
Collaborator

@SmittieC SmittieC left a comment

Choose a reason for hiding this comment

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

Looks good to me 🚀

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

Successfully merging this pull request may close these issues.

4 participants