-
Notifications
You must be signed in to change notification settings - Fork 86
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
Canonical Stats #13
Comments
From looking at the code the database lookup in Given that I restarted the service to see how it would handle loading back from the database, and now the stats show I'd like to unify this behaviour so either the in-memory stats store strips My feeling is strip (I'd also like to add this is a pretty useful tool. It's already replaced most of my bookmarks bar. Thanks for releasing it.) |
The intent was certainly that we store stats based on the canonical link name. Sounds like that got screwed up. Thanks for pointing it out. I'll take a closer look today. |
I can't seem to reproduce this, and I think there might be something missing... did you rename the link on the detail page? The sqlite schema has two different fields for the link name: ID and Short. Short is the name exactly as the user entered (the "preferred rendering" of the name), while ID is the normalized version (all lowercase, hyphens removed, etc). When resolving a link, we normalize whatever the user specified, then do a lookup by that normalized ID. However, we when store stats, we always use the current Short value (regardless of what the user entered). So you should be able to visit The one thing we don't handle is coalescing stats when the preferred name for a link is changed. Once you change the preferred name, all future ClickStats will use that new name, but we don't go back and change old stats with the old name. This was an intentional design choice to keep the data model simple, and because we didn't expect that the preferred name for a link was likely to change often. Does that track with the behavior you're seeing? |
I don't recall renaming the link, just initially created it as I've just tried reproducing this locally with the latest docker image and it's functioning as expected. The instance I saw the issue with is running 76c67c0 according to podman, but I don't see any relevant changes between there and current main. The entries in the stats table are all coalesced to the same value Just tried upgrading the container with the issue to latest main (5fefe25) and it still shows the same behaviour there. |
ah, got it! That makes sense and now I see the problem... When a golink is visited, we directly store the click in the in-memory stats map, and also queue it up to be save to the database later. When saving to the in-memory map, we store the canonical short name. When it eventually gets stored in the database, we store the normalized id. So on startup, when we load historical stats from the database, those all have the normalized IDs, and then subsequent clicks use the short name again. My intent was always to use the preferred canonical short name in the stats, so I think we just need to map the IDs to short names on cold startup. |
When loading stats from the database, map IDs back to their canonical short name, which is what we want to show in the frontend. This is only called once on cold start, so performance of loading all links isn't a big concern. Fixes #13
When loading stats from the database, map IDs back to their canonical short name, which is what we want to show in the frontend. This is only called once on cold start, so performance of loading all links isn't a big concern. Fixes #13 Signed-off-by: Will Norris <[email protected]>
When loading stats from the database, map IDs back to their canonical short name, which is what we want to show in the frontend. This is only called once on cold start, so performance of loading all links isn't a big concern. Fixes #13 Signed-off-by: Will Norris <[email protected]>
I'm not actually sure if this is an issue, but it surprised me so I thought I'd query it.
I've defined
go/cu-devops
to take me to our DevOps work board (think Trello), and that works fine. Shows up in the stats asgo/cu-devops
.I then remembered the logic strips
-
so I could visitgo/cudevops
and did so. This shows up as a separate entry in the stats now, although clicking the (i) on eithergo/cu-devops
orgo/cudevops
shows thego/cu-devops
Link to be edited.Should we coalesce the stats entries to the Link value, so missing out hypens doesn't duplicate entries for the same Link?
The text was updated successfully, but these errors were encountered: