-
Notifications
You must be signed in to change notification settings - Fork 6
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
GO-247 Allow filtering out threads with visible tags with query -label:* #90
Conversation
|
||
with_text = query.to_s | ||
|
||
query.to_s.scan(/(-?label):\(([^)]+)\)/).each do |match| | ||
raise "unexpected label case" if match.length != 2 | ||
query.to_s.scan(/(-?label):\(([^)]+)\)|(-label:\*)/).each do |match| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ked si tu das takyto regular tak budes mat podporu aj pre bez zatvoriek aj * a vsetko najdes ako potrebujes a nemusis tu kuzlit. https://regex101.com/
((-?)label):(\(([^)]+)\)|([^ ]+)|\*)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuchal ok. upravim to teda takto. len tam tam vznika taka mensia haluz. kym -label:*
ma specialny vyznam, tak label:*
nema ziadny vyznam. za mna je to ok, ja len aby sa vedelo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label:* asi znamena, ze to ma nejaky tag ale to by som asi neriesil.
Tag.where(tenant_id: tenant_id, name: label_names).pluck(:id) | ||
end | ||
|
||
def self.visible_tag_ids(tenant_id) | ||
Tag.where(tenant_id: tenant_id, visible: true).pluck(:id) | ||
if label_names.find { |name| name == "*" }.present? | ||
[true, Tag.where(tenant_id: tenant_id, visible: true).pluck(:id)] | ||
else | ||
ids = Tag.where(tenant_id: tenant_id, name: label_names).pluck(:id) | ||
[ids.length == label_names.length, ids] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nemalo by toto byt nad Tag
ako nejake tenant.tags.find_by_names(names).pluck(:id)
a do metody posielame tenant a nie tenant_id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moze byt aj tak. tak, ako to je tu, to ale mame prakticky vsade v XxxPolicy
.
Admin::UserPolicy < Struct.new(:user) # to som spravil umelo prezjednodusenie
class Scope < Scope
def resolve
if @user.site_admin?
scope.all
else
scope.where(tenant_id: @user.tenant_id)
end
end
end
v com vidis rozdiel to pisat tak, ako navrhujes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Za mna je best-practice
- specialne v pripadoch kedy sa obmedzuje viditelnost pouzivat parent asociaciu ako zaciatok
- primitive obsession - s idckami by sa malo babrat primarne na top level urovni, alebo v jasne definovanych interfacoch. Inak bude vsade
_id
a.id
namiesto objektu samotneho. - je to domenovy jazyk, to vyssie je taky implementacny jazyk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuchal nahradit to v tom Query za tenant
je v pohode. len teda tu
https://github.com/solver-it-sro/govbox-pro/blob/main/app/models/searchable/message_thread.rb#L32
potrebujem tenant_id
. a neviem ist cez tenant
takto pekne, predoze tam mi prichadza uz nejaky scope
. cize tam je jedina moznost mat tam fetch(:tenant).id
(ak si tam teda nechcem posiet aj tenant
a aj tenant_id
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smerom na search je podla mna ok kontrakt cez idcka lebo to su ine domeny.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tak nakoniec som tam nechal tenant
, lebo som si uvedomil, ze where(tenant_id: tenant)
pekne nacita id z daneho objektu.
result = { tenant_id: Current.tenant } | ||
result[:box_id] = Current.box if Current.box | ||
result = { tenant: Current.tenant } | ||
result[:box] = Current.box if Current.box | ||
result[:tag_ids] = policy_scope(Tag).pluck(:id) unless Current.user.admin? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Myslim, ze tu podmienku mozeme vyhodit, momentalne adminom uz davame pristupy na vsetky tagy default, ze @luciajanikova ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found_all, filter_tag_ids = label_names_to_tag_ids(tenant, filter_labels) | ||
_, filter_out_tag_ids = label_names_to_tag_ids(tenant, filter_out_labels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu daj TODO, ze toto by sa dalo aj jednou query vybavit.
No description provided.