Unverified Commit 78147685 authored by mvdbeek's avatar mvdbeek
Browse files

Don't create unnecessary histories for anon users

The previous galaxy_session.user guard meant that anon
users would always get a new history.
parent b73d9e29
Loading
Loading
Loading
Loading
+24 −23
Original line number Diff line number Diff line
@@ -912,16 +912,17 @@ class GalaxyWebTransaction(base.DefaultWebTransaction, context.ProvidesHistoryCo
        Gets or creates a default history and associates it with the current
        session.
        """
        history = self.galaxy_session.current_history
        if history and not history.deleted:
            return history

        # There must be a user to fetch a default history.
        if not self.galaxy_session.user:
            return self.new_history()

        user = self.galaxy_session.user
        if user:
            # Look for default history that (a) has default name + is not deleted and
            # (b) has no datasets. If suitable history found, use it; otherwise, create
            # new history.
            stmt = select(self.app.model.History).filter_by(
            user=self.galaxy_session.user, name=self.app.model.History.default_name, deleted=False
                user=user, name=self.app.model.History.default_name, deleted=False
            )
            unnamed_histories = self.sa_session.scalars(stmt)
            default_history = None