Skip to content

Conversation

@moliholy
Copy link
Contributor

@moliholy moliholy commented Feb 14, 2024

Closes #6127

Description

This PR adds the possibility to filter in the calendar by keywords.

Keywords can now be registered system-wise so that there is a limited amount of allowed one. If there is no system-wide allowed keywords then the option to filter by keyword is not shown.

Also when editing a booking's keywords different widgets are used to limit the possibilities if needed. Otherwise the old widget is used.

Screenshots

Screenshot 2024-02-14 at 16 23 13 Screenshot 2024-02-14 at 16 22 55

@ThiefMaster
Copy link
Member

I'll soon merge #6177, you can most likely make use of that field (originally that was @OmeGak's suggestion)

@moliholy moliholy force-pushed the keywords branch 5 times, most recently from 53c2e8e to 238d101 Compare February 16, 2024 12:00
@ThiefMaster
Copy link
Member

I'm merging #6177 now so maybe see if you can use that for the dropdown field

@moliholy
Copy link
Contributor Author

I'm merging #6177 now so maybe see if you can use that for the dropdown field

@ThiefMaster this PR is now using the new widget!

Screenshot 2024-02-21 at 15 10 59


def _get_event_data(self, event_query):
def calculate_keyword_id(kw):
return crc32(kw) + 3
Copy link
Member

Choose a reason for hiding this comment

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

I think the + 3 here deserves a comment - at least I have no clue after reading over the code (up until this line) why this is 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.

It's in order not to collide with IDs 0 and 1, which are reserved. I'll add a comment.

Copy link
Member

Choose a reason for hiding this comment

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

I think getting a CRC32 that's 0 or 1 is quite uncommon (but apparently not impossible, even though the examples I found on Stack Overflow did not yield 0 for me).

Do those IDs really need to be numeric though? If not we could even use the keyword itself for the keywords...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, they are numerics (category ID, venue ID, room ID, etc.) so for consistency I'd definitely prefer it to be numeric. As for the +3, it's just to be 100% covered against collisions.

Copy link
Member

Choose a reason for hiding this comment

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

crc32 by itself is not collision-proof :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No hashing algorithm is 100% collision proof, but it should be at least extremely unlikely to have a collision. In any case, what do you suggest we should do here? I don't have an strong opinion here, but I'd definitely prefer to keep the ID as an integer for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a super strong opinion either, but if there's nothing that really depends on them being numeric it feels much nicer to be able to just use the strings. Also if you ever need to debug something and look at the actual data...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless there's a strong reason (and inspecting the IDs is definitely not one of them, at least for me) to change the ID from integer to string my vote goes straightforwardly for maintaining it as a number. How that number gets generated I don't care though.

@ThiefMaster
Copy link
Member

I think there's a bug somewhere in the keyword filtering logic.

I have an event with the keywords cavities, theory, lhc. I only see that event if I have these two filters enabled (both of them, just one is not enough):

image

I think a filter for "multiple keywords" (clearer than "many keywords" IMHO) makes sense in case you want to see which events have multiple keywords. But this should not be a requirements to see such events at all: When I filter by a single keywords, I'd expect to see all events that contain this keyword!

@moliholy moliholy force-pushed the keywords branch 2 times, most recently from 4768919 to ae7c5ad Compare February 28, 2024 11:13
@moliholy
Copy link
Contributor Author

I think there's a bug somewhere in the keyword filtering logic.

@ThiefMaster I just pushed a commit that I think implements the behaviour you describe. Would you mind to check it out?

@ThiefMaster
Copy link
Member

works fine now! :)

ThiefMaster and others added 4 commits March 5, 2024 17:14
Error only shows when someone messes around with the submitted data, no
need to have people translate that
@ThiefMaster ThiefMaster added this to the v3.3 milestone Mar 5, 2024
@ThiefMaster ThiefMaster enabled auto-merge (squash) March 5, 2024 17:07
@ThiefMaster ThiefMaster merged commit 57980ee into indico:master Mar 5, 2024
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.

Add per-keyword coloring and legend in event calendar view

2 participants