Commit Graph

88 Commits

Author SHA1 Message Date
Klaas van Schelven
91b99af08d project-alert edits: fix misalignments (by asking ChatGPT) 2025-07-28 22:18:02 +02:00
copilot-swe-agent[bot]
21ee428938 Add UI components to display alert backend failure status
Co-authored-by: vanschelven <223833+vanschelven@users.noreply.github.com>
2025-07-28 22:13:22 +02:00
Klaas van Schelven
2b46bfe9a1 Project-edit: redirect to list on-save 2025-07-14 16:08:30 +02:00
Klaas van Schelven
3baedcaab9 Project-delete: show success-message after delete 2025-07-07 12:48:35 +02:00
Klaas van Schelven
f21d9f989b Fix recently added UI elements to have dark mode too
the elements were added after the work on #125 was done but in a
branch w/o dark-mode, so they needed to still be fixed
2025-07-07 11:39:27 +02:00
Klaas van Schelven
d99f946665 Merge branch 'main' into feature/add_dark_theme 2025-07-07 11:08:00 +02:00
Klaas van Schelven
7b340fd8ff Hide in-progress deletions of Project & Issue from the UI
I've done a full grep on Issue.objects, Project.objects and get_object_or_404
equivelents, and applying some common sense. The goal: avoid having
confusing/half-broken pages in the UI.

On index-usage: I've decided not to update the indexes. The assumption is:
`is_deleted` items will be a tiny minority of items in general, making the
cost/benefit analysis not turn out favorably (just scanning them out as a final
step is more efficient).  Also: sqlite is able to use the correct index without
adding a special one, proof:

```
EXPLAIN QUERY PLAN SELECT [..] WHERE ("issues_issue"."project_id" = 1 AND "issues_issue"."is_muted" = (0) AND "issues_issue"."is_resolved" = (0)) ORDER BY "issues_issue"."last_seen" DESC LIMIT 250;
QUERY PLAN
`--SEARCH issues_issue USING INDEX issue_list_open (project_id=? AND is_resolved=? AND is_muted=?)

EXPLAIN QUERY PLAN SELECT [..] WHERE ("issues_issue"."project_id" = 1 AND "issues_issue"."is_muted" = (0) AND "issues_issue"."is_resolved" = (0) AND "issues_issue"."is_deleted" = 0) ORDER BY "issues_issue"."last_seen" DESC LIMIT 250;
QUERY PLAN
`--SEARCH issues_issue USING INDEX issue_list_open (project_id=? AND is_resolved=? AND is_muted=?)
```

See #139 for the 0/1 notation in the above.

(Project-indexes: not an issue, the scale is "below relevance for indexes")
2025-07-07 10:27:36 +02:00
Animesh Agrawal
72479fe982 add button for project-delete in UI
Implement delete functionality with confirmation modals for projects.

cherry picked (by Klaas) from commit 6764fbf343fb; but:

* projects only
* `delete_deferred`
* flake8

See #84 for the original PR
2025-07-04 17:33:02 +02:00
Klaas van Schelven
4900f0447e Project-deletion: slight optimization
Removes the following 2 redundant queries from the deletion process:

```
SELECT "tags_tagkey"."id" FROM "tags_tagkey" WHERE "tags_tagkey"."project_id" IN (1) ORDER BY "tags_tagkey"."project_id" ASC, "tags_tagkey"."id" ASC LIMIT 498
UPDATE "projects_project" SET "stored_event_count" = ("projects_project"."stored_event_count" - 1) WHERE "projects_project"."id" = 1
```
2025-07-03 22:04:51 +02:00
Klaas van Schelven
28b2ce0eaf Various models: .project SET_NULL => DO_NOTHING
Like e45c61d6f0, but for .project.

I originally thought `SET_NULL` would be a good way to "do stuff later", but
that's only so the degree that [1] updates are cheaper than deletes and [2]
2nd-order effects (further deletes in the dep-tree) are avoided.

Now that we have explicit Project-deletion (deps-first, delayed, properly batched)
the SET_NULL behavior is always a no-op (but with cost in queries).

As a result, in the test for project deletion (which has deletes for many
of the altered models), the following 12 queries are no longer done:

```
SELECT "projects_project"."id", [..many fields..] FROM "projects_project" WHERE "projects_project"."id" = 1
DELETE FROM "projects_projectmembership" WHERE "projects_projectmembership"."project_id" IN (1)
DELETE FROM "alerts_messagingserviceconfig" WHERE "alerts_messagingserviceconfig"."project_id" IN (1)
UPDATE "releases_release" SET "project_id" = NULL WHERE "releases_release"."project_id" IN (1)
UPDATE "issues_issue" SET "project_id" = NULL WHERE "issues_issue"."project_id" IN (1)
UPDATE "issues_grouping" SET "project_id" = NULL WHERE "issues_grouping"."project_id" IN (1)
UPDATE "events_event" SET "project_id" = NULL WHERE "events_event"."project_id" IN (1)
UPDATE "tags_tagkey" SET "project_id" = NULL WHERE "tags_tagkey"."project_id" IN (1)
UPDATE "tags_tagvalue" SET "project_id" = NULL WHERE "tags_tagvalue"."project_id" IN (1)
UPDATE "tags_eventtag" SET "project_id" = NULL WHERE "tags_eventtag"."project_id" IN (1)
UPDATE "tags_issuetag" SET "project_id" = NULL WHERE "tags_issuetag"."project_id" IN (1)
```
2025-07-03 21:49:49 +02:00
Klaas van Schelven
6b9e4d8011 Project.delete_deferred(): first version (WIP)
Implemented using a batch-wise dependency-scanner in delayed
(snappea) style.

* no real point-of-entry in the (regular, non-admin) UI yet.
* no hiding of Projects which are delete-in-progress from the UI

* lack of DRY
* some unnessary work (needed in the Issue-context, but not here)
  is still being done.

See #50
2025-07-03 21:01:28 +02:00
Fabien LEFEBVRE (d1ceward)
9cec248ad8 Add dark theme 2025-06-16 15:37:37 +02:00
Klaas van Schelven
fac5b19966 Slack Alerts
Fix #3
2025-06-10 22:00:37 +02:00
Klaas van Schelven
17fb9cc850 Remove open_issue_count from homepage; it's too expensive 2025-05-06 10:27:16 +02:00
Klaas van Schelven
6e0f1f0f54 Document team/project visibility/access design 2025-04-04 10:01:38 +02:00
Klaas van Schelven
8fc6f752cf Allow users to join their own team's projects
Fix #56

Looked into this for a while, but I think it was simply an oversight in
the logic-as-programmed; if you're part of a team, you should be able
to just click 'join' on any of that team's projects and be a project-member
2025-04-03 16:28:35 +02:00
Klaas van Schelven
427a2a341e Change tab header into "Team Projects"
It said "Other Team Projects", which has 2 ways to be read:

* "Other (Team Projects)" (the correct one)
* "(Other Team) Projects" (the incorrect one)
2025-04-03 16:23:06 +02:00
Klaas van Schelven
9e683d8c9d retention_max_event_count: in project settings form
somewhere, there's a case that such settings need a different level of
authorization; (just because you're the admin of the project doesn't mean you
should be able to do things that affect the system as a whole) but we don't
have such a level ATM.
2025-03-31 16:00:20 +02:00
Klaas van Schelven
12d7ce5629 Flake8: for migrations _just_ ignore the whitespace errors
this helps catching some _real_ errors while saving us from having to format
automatically generated code
2025-02-06 16:41:43 +01:00
Klaas van Schelven
615d2da4c8 Chache stored_event_count (on Issue and Projet)
"possibly expensive" turned out to be "actually expensive". On 'emu', with 1.5M
events, the counts take 85 and 154 ms for Project and Issue respectively;
bottlenecking our digestion to ~3 events/s.

Note: this is single-issue, single-project (presumably, the cost would be lower
for more spread-out cases)

Note on indexes: Event already has indexes for both Project & Issue (though as
the first item in a multi-column index). Without checking further: that appears
to not "magically solve counting".

This commit also optimizes the .count() on the issue-detail event list (via
Paginator).

This commit also slightly changes the value passed as `stored_event_count` to
be used for `get_random_irrelevance` to be the post-evication value. That won't
matter much in practice, but is slightly more correct IMHO.
2025-02-06 16:24:25 +01:00
Klaas van Schelven
86e8c4318b Add indexes on fields on which we order and vice versa
Triggered by issue_event_list being more than 5s on "emu" (my 1,500,000 event
test-machine). Reason: sorting those events on non-indexed field. Switching
to a field-with-index solved it.

I then analysed (grepped) for "ordering" and "order_by" and set indexes
accordingly and more or less indiscriminately (i.e. even on tables that are
assumed to have relatively few rows, such as Project & Team).
2025-02-04 21:19:24 +01:00
Klaas van Schelven
0b42d3ff1e Semi-manual squash-migrations
## Goal

Reduce the number of migrations for _fresh installs_ of Bugsink. This implies: squash as
broadly as possible.

## How?

"throw-away-and-rerun". In particular, for a given app:

* throw away the migrations from some starting point up until and including the last one.
* run "makemigrations" for that app. Django will see what's missing and just redo it
* rename to 000n_b_squashed or similar.
* manually set a `replaces` list on the migration to the just-removed migrations
* manually check dependencies; check that they are:
    * as low as possible, e.g. an FK should only depend on existence. this reduces the
      risk of circular dependencies.
    * pointing to "original migrations", i.e. not to a just-created squashed migration.
      because the squashed migrations "contain a lot" they increase the risk of circular
      dependencies.
* restore (git checkout) the thrown-away migration

## Further tips:

* "Some starting point" is often not 0000, but some higher number (see e.g. the outcome
  in the present commit). Leaving the migrations for creation of base models (Event,
  Issue, Project) in place saves you from a lot of circular dependency problems.
* Move db.sqlite3 out of the way to avoid superfluous warnings.

## RunPython worries

I grepped for RunPython in the replaced migrations, with the following results:

* phonehome's create_installation_id was copied-over to the squashed migration.
* all others where ignored, because:
    * they "do something with events", i.e. only when events are present will they have
      an effect. This means they are no-ops for _new installs_.
    * for existing installs, for any given app, they will only be missed (replaced) when
      the first replaced migration is not yet executed.

I used the following command (reading from the bottom) to establish that this means only
people that did a fresh install after 8ad6059722 (June 14, 2024), but before
c01d332e18 (July 16) _and then never did any upgrades_ would be affected. There are no
such people.

git log --name-only \
    events/migrations/0004_event_irrelevance_for_retention.py \
    issues/migrations/0004_rename_event_count_issue_digested_event_count.py \
    phonehome/migrations/0001_initial.py \
    projects/migrations/0002_initial.py \
    teams/migrations/0001_initial.py

Note that the above observation still be true for the next squashmigration (assuming
squashing starting at the same starting migrations).

## Cleanup of the replaced migrations

Django says:

> Once you’ve squashed your migration, you should then commit it alongside the
> migrations it replaces and distribute this change to all running instances of your
> application, making sure that they run migrate to store the change in their database.

Given that I'm not in control of all running instances of my application, this means the
cleanup must not happen "too soon", and only after announcing a migration path ("update
to version X before updating to version Y").

## Roads not taken

Q: Why not just do squashmigrations? A: It didn't work reliably (for me), presumably b/c
of the high number of strongly interdependant apps in combination with some RunPython.

Seen after I was mostly done, not explored seriously (yet):

* https://github.com/3YOURMIND/django-replace-migrations
* https://pypi.org/project/django-squash/
* https://django-extensions.readthedocs.io/en/latest/delete_squashed_migrations.html
2025-02-03 16:06:17 +01:00
Klaas van Schelven
0ec809cbb3 Simplify migration deps and document them 2025-02-03 14:04:44 +01:00
Klaas van Schelven
59372aba33 First version of multi-tenant setup (EE) 2025-01-29 09:04:19 +01:00
Klaas van Schelven
c6adfd7511 Remove 'slug' field from team
it was unused; probably added analogously with project (where it _is_ used)
2025-01-24 10:21:39 +01:00
Klaas van Schelven
2739422968 Generic SDK: link to 'list of issues' 2024-12-16 21:50:19 +01:00
Klaas van Schelven
28314a2683 Language icons: add to SDK page 2024-12-03 09:14:29 +01:00
Klaas van Schelven
93ce454fb4 SDK setup icon: use a plug 2024-11-29 09:19:26 +01:00
Klaas van Schelven
944f9d9a84 Add title tags to (parent elements of) svg icons 2024-11-29 08:25:11 +01:00
Klaas van Schelven
b8eff86971 SDK: specific instructions on reporting issues 2024-11-28 16:34:59 +01:00
Klaas van Schelven
719fcae322 Friendly 400 page that shows the error, even when DEBUG=False
when people run into ALLOWED_HOSTS troubles, they should get info on-screen ASAP
2024-11-28 12:43:14 +01:00
Klaas van Schelven
cf4a1dbeb6 Project/team help_text 2024-11-20 14:33:04 +01:00
Klaas van Schelven
bbd444dca1 SDK: platform-specific notes for PHP, JS 2024-11-20 12:09:45 +01:00
Klaas van Schelven
86d8577a4f SDK instructions: use texts from sdkconf; point to website for further info 2024-11-19 12:37:37 +01:00
Klaas van Schelven
2569ec4ac5 SDK instructions factored out to separate package 2024-11-19 09:25:27 +01:00
Klaas van Schelven
9e882fafa0 DSN page: verification of the setup should be more explicit
during user-testing, it was revealed that people think there is something
wrong when they see 'DivisionByZero' when this is in fact precisely what
was intended. Hopefully the new text removes this confusion
2024-11-15 16:43:27 +01:00
Klaas van Schelven
98e666e3ff Remove dashses from displayed DSN
Fixes #7

I could not find any documentation on what the "standard" is, but I know that
we'll pick it up just fine either way (because Django's UUID field does the
magic for us).

Given that it's impossible to setup your JS client with the dashes, they should
simply be removed.
2024-10-14 20:15:45 +02:00
Klaas van Schelven
8ee526776e Show 'no version' on a button when this applies 2024-09-30 21:22:34 +02:00
Klaas van Schelven
b43d1cfa05 action must be non-empty 2024-09-26 15:27:46 +02:00
Klaas van Schelven
23b2a70797 remove magic number in favor of method 2024-09-17 21:36:41 +02:00
Klaas van Schelven
79c9413256 Remove TODO about indexing on Project (id, sentry_key)
This was probably about the making Project.objects.get(id, sentry_key)
more efficient, but

* I don't have an indication it's a bottleneck
* It may very well be turned into a get-by-id, check-for-key idiom,
  in which case the index won't help.
2024-09-13 10:03:20 +02:00
Klaas van Schelven
e59fd3a225 Implement 'occurs_in_last_release' 2024-09-12 09:49:22 +02:00
Klaas van Schelven
c893293c50 textual, SDK setup (WIP) 2024-09-11 09:23:16 +02:00
Klaas van Schelven
02687ff9f4 Fix new-project permission-check
to match what I already had decided the model was, namely the condition for 'can_create'
in the project_list view
2024-09-10 09:02:30 +02:00
Klaas van Schelven
d4d292e4be Remove perm-based permission-checks
For now, sticking to "how it actually works" is more important than "what we
might need in the future". We don't have an admin-group with actually handed
out perms yet, and we do have the recommendation to create a superuser in the
installation docs. So let's just explicity check for that.

(I found these checks while working on actual breakage in the previous commit)
2024-09-10 08:51:00 +02:00
Klaas van Schelven
a8c5e447c8 atomic_for_request_method: put on teams/projects views too
discovered while playing with mysql;
drive-by change, i.e. not yet tested.
2024-08-28 15:08:41 +02:00
Klaas van Schelven
70fdbc9cbd Sentry DSN setup: recommend what we do ourselves 2024-08-22 10:03:28 +02:00
Klaas van Schelven
51a53c09a4 quota: check as little as possible & check-on-digest
Also fix various off-by-one errors with the help of tests
2024-07-17 14:48:19 +02:00
Klaas van Schelven
8849a3e44b Don't write to the DB on-ingest
In the previous commit I put the code for a small performance-experiment.
The results are (very) obvious: don't do this. Response times go through
the roof, and more importantly, the server becomes unreliable. Reason:
time-outs caused by waiting for the write-lock.
2024-07-16 16:39:12 +02:00
Klaas van Schelven
0c964cfcc8 Add project.ingested_event_count (input for performance-experiment) 2024-07-16 15:48:16 +02:00