►
Description
In this session we discuss and explore simplifying common "Finder" responsibilities such as ordering and paginating.
C
If
you
go
back
to
the
to
the
ui
most
models
that
use
this
view
and
correct
me
if
I'm
wrong,
terry
or
alexandria
or
lee,
I
believe
most
models
that
use
this
view
are
issuables.
B
D
I
think
we
have
others
as
well
like.
I
think
we
use
this
searchable
thing
so
by
models
you
mean.
C
A
C
And
it
is
my
understanding
that
incidents
are
fall
under
the
issuable
umbrella,
correct
the
the
thing
about
that
is
like
we
to
create
this
reusable
behavior.
Unfortunately,
with
like
workshop,
like
we
looked
at,
merge
requests
issues
and
all
the
things
that
looked
you
know
if
you
squint
your
eyes
hard
enough,
it
looks
like
an
issue
we
created
this
base
class
issuable
and
that's
how
most
of
the
reusable
behavior
is.
C
But
now
we
kind
of
have
this
god-based
class
issuable,
which
is
in
charge
of
way
too
much,
and
it
has
functionality
that
you
can't
really
extract
from
it
easily
or
reuse
just
easily
with
this
like
active
inactive
counts
and
the
pagination
and
stuff
like
that.
So
like
a
base,
I
mean
using
inheritance,
isn't
the
best
tool
for
creating
the
reusable
behavior.
C
A
Good,
so
this
is,
I'm
just
gonna,
add
a
whole
another
level
of
whatever
I
want
to
call
it
as
well,
so
that
that
was
only
half
of
the
problem.
I
also
had
to
create
this
nasty
thing
for
handling
the
sorting
on
the
back
end
and
again,
I
feel
like
this.
There
must
have
been
a
much
much
easier
drier,
reusable
way
of
doing
this.
So,
let's,
let's
just
throw
this
whole
kind
of
what
is
life
into
the
mix.
D
I
guess
there
is:
there
are
some
ways
to
kind
of
instead
of
doing
all
that,
just
to
just
define
some,
how
do
you
call
them
annotation
like
things
where
you
just
list
the
things
that
you
want
to
sort
by
and
then
it
will
create
all
of
this
stuff
for
you,
so
yeah.
D
No,
I
don't
think
we
do
that.
Well,
we
kind
of
do
that,
but
not
for
these
type
of
things,
but
we
do
it,
for
instance,
to
annotate
something
as
being.
D
Let
me
think
like
mentionable
so
like
you
would
say
that
the
title
and
the
description
is
something
that
is
mentionable,
which
means
that
it
will
get
parsed
for
any
sort
of
references
like
reference
to
user,
to
project,
to
an
issue
and
so
on
and
so
forth.
D
A
D
A
Like
an
interesting
yeah
and
I'm
going
to
open
up
one
more
because
I
had
to
do
this
somewhere
else
as
well,
contact
saw
enum,
so
I
just
had
to
create
so
much
boilerplate.
D
A
D
Yeah
that
can
be,
I
think
we
have
examples
where
you
just
list
this
in
an
array
and
then
reuse
it
in
all
these
places.
So
then
you
can
iterate
through
the
basically
through
the
array
and
not
have
to
write
every
single
line
of
that.
B
A
D
Yeah,
but
I
I
I
kind
of
see
what
you're
saying,
for
instance,
for
pagination
right
you
I
think
we
can
have
something
more
implemented
like
more
basic
and
and
did
not
have
to
do
that
for
every
single
dissolver,
because
I
guess
you
can
generalize
that
every
resolver
would
want
to
be
paginated
anyway.
So.
C
Can
can
you,
can
you
clarify
what
the
sorts
are
doing
on
the
model.
A
Yeah,
that's
a
good
good
point.
So
first
thing,
as
I
understand
it,
you
shouldn't
really.
This
could
be
completely
wrong.
It
might
be
that
sorting's,
okay
in
finders
in
certain
places,
but
I
know
we've
got
cops
and
best
practices
that
say
that
you
should
only
do
certain
things
in
the
model,
for
example,
and
I
think
maybe
sorting's
one
of
those.
D
Now
the
scopes
need
to
be
so
so
you
cannot
do
or
they're
in
in
the
finders
and
so
on.
You
want
it
to
be
defined
in
one
place
and
that's
the
model
like
what
becomes
kind
of
tricky.
Is
you
have
this
organization
sorting
right
so
now
you
need
to
do
join,
but
there
is
no
easy
way
to
know
which
ones
of
this
need
to
have
the
join
and
which
ones
don't
need
to
have
to
join.
B
C
The
glue
code
without
having
to
manually
implement
it
every
time,
but
then
I
don't
think
we
have
any
kind
of
like
like
abs,
abstract,
finder,
the
right
might.
The
only
abstract
finder
I
think
we
have
is,
is
an
issuable
finder
like
this,
but
that's.
C
And
I
don't
play
around
the
backend
code
a
whole
lot,
but
I
I
don't
see
what
would
prevent
us
having
like
an
abstract
finder,
and
maybe
that
would
be
more
make
more
sense
than
trying
to
attach
like
includes
or
mixing
something
into
the
model
like
keeping
all
this
reusable
code
in
the
model.
Maybe
that's
problematic.
Maybe
we
want
to
have
a
reusable
finder
or
something
like
what,
if
this
contacts
finder
was
more
abstract,
is
that.
C
D
I
I
think
it's
difficult
to
to
have
an
abstract
finder
in
the
sense
that
you'll
you'll
want
to
extend
it
anyway,
like
every
single
model,
is
so
different
from
everything
else
right,
the
the
even
though
it
like
it
feels
it
does
the
same
thing
in
like
searching
through
a
table.
It
still
has
its
own
attributes,
first
name
last
name,
which
is
not
in
the
issue
right.
So
then
the
abstract
model
doesn't
feel
like
it
will
actually
do
anything.
D
A
Is
interesting,
I
may
be
misunderstanding
sort
of
where
you're
headed
paul
but
sort
of
like
looking
at
this
and
thinking
well.
Here
I've
I've
got
sort
of
something
which
seems
a
bit
okay,
so
this
is
kind
of
like
a
validation,
that's
kind
of
specific
to
contacts.
A
But
then
we
grab
I'm
going
to
call
it
like
the
master
list,
and
then
we
apply
all
of
the
filters
and
then
we
apply
sorting
and
conditionally
depending
on
whether
we're
counting
we've
then
got
this.
So
each
of
these
things
does
feel
like
it
could
be
fairly
abstracted
to
some
kind
of
interface.
If
that's
the
right
term
in
ruby,
where
you
know,
what's
the
what's
the
sorting
logic,
what's
the
I
mean.
C
D
C
Imagine
being
in
search,
you're
really
really
familiar
with
this
some
of
these
yeah,
but.
C
So
first,
the
this
pattern
that
happened
with
hp
levels
is
just
a
little
frustrating
to
me
because,
like
we're,
this
is
old
old,
gitlab
code
and
we're
regularly
paying
off.
You
know
this
paying
the
interest
of
this
technical
debt
of
encapsulating
this
reusable
behavior
through
inheritance
and
issuable
is
not
a
really
great
abstraction
as
merge
requests
and
issues.
You
know
they
may
have
looked
really
similar
at
one
point
and
then
they
really
diverged,
and
then
you
have
other
things
like
issuables
and
things
get
really
complex
with
issuable
land.
B
Yeah,
I've
even
seen
sometimes
where
there's
like
front-end
stuff,
where
people
are
starting
to
like
separate
things
out
and
be
like
very
specific
about
like.
Actually,
this
isn't
just
issuable.
This
is
only
for
merge
requests
and
so,
like
you,
just
need
to
remove
the
whole
like
remove
the.
C
Yeah,
it
gets
weird
where
it's
like
we'll
have
in
the
front
end
code.
There's
things
like
if
issue
type
equals
merge
requests
like
you,
get
weird
weird
lines
like
that.
So
this
is
a
very
complex
finder,
obviously,
and
but
I
do
feel
like
hey,
there's,
there's
need
for.
C
D
B
B
D
And
then
look
for
I
yeah
like
like
this,
like
redact
field
right.
So
what
this
would
do
is
basically
would
do
some
stuff
on
the
on
the
description
field,
so
that
we
can
do
something
like
this
within
the
finders.
I
would
guess
where
you'd
say
scope
by
like
first
name
or
order
by
first
name.
So,
instead
of
writing
the
method
you'd
do
this
and
then
you'd
have
a.
D
Seen
a
helper
method
that
will
take
this
params
and
just
implement
basically
the
benefit
for
you
yeah.
Something
like
that.
I'm
not
a
huge
fan
of
this
because
yeah,
it
kind
of
hides
something.
C
C
I
don't
really
need
to
test
these
like
the
annotation
works,
but
it
can
cause
like
catastrophic
issues
if
you
get
something
wrong
there,
that's
a
that's
an
interesting
point,
so
the
other
like
approach
to
like
solving
boilerplate
is
generating
code
and
have
have
you
all
in
the
back
and
never
talked
about
like
code
generators.
C
A
Definitely
a
red
flag.
The
only
thing
that
immediately
springs
to
mind.
Another
community
contributors
recently
made
some
changes
to
the.
I
forget
what
they're
called
exactly,
but
the
rails
model
template
generator.
So
when
you
do
like
rails
g
generate
migration,
it
creates
a
new
model
and
a
little
bit
of
boilerplate
around
like
a
migration
script
and
a
model
and
a
few
bits
like
that.
A
So
yeah
I
mean
when
you
think
about
it,
is
generally
speaking
when
you
create
a
new
model
you're
going
to
want
the
model
itself,
you're
going
to
want
a
spec
for
the
model
you're
going
to
want
the
migration
script,
to
create
the
table,
you're
going
to
want
a
finder,
a
graphql
type,
there's
quite
a
lot
of
stuff,
but
I
guess
all
at
different
points
in
time.
Like
I
know
with
this,
we
didn't
create
a
contact
finder.
A
Initially
it
wasn't
needed
until
we
introduced
a
way
to
search
for
contacts
or
yeah
and
and
the
same
thing
here.
You
know
we
didn't
need
the
counts
until
we
decided
we
wanted
to
improve
the
list
and
add
the
pagination
and
all
that
kind
of
stuff.
So
but
that
being
said,
I
don't
think
it
would
be
bad
if
these
things
were
there
from
the
beginning,
but
I'm
not
sure
I
would
be
very
overly
comfortable
on
the
pattern
being
that
yeah
the
code
is
generated
as
opposed
to
I
I
really
like
you
know.
A
When
I
first
manually
wrote
a
validation,
would
it
be
validation?
I
don't
know
if
it's
validation
but
a
method
that
essentially
stripped
white
space
from
the
end
of
these
fields
and
then
some
reviewer
or
maintainer
said
hey,
like
we've
got
something
that
does
that
you
don't
need
to
rewrite
that
code,
and
that
was
like
awesome,
wicked
great.
A
D
Yeah,
I
think
we
can
like
we
can
create
something
like
strip
attribute
for
the
finders
and
and
just
instead
of
that,
do
filter
by
and
then
specify
the
and
at
least
that
will
work
for
like
very
simplistic
filters.
And
then,
if
you
need
anything,
that's
more
complicated
than
that.
You
just
write
your
own
method
or
something
right.
B
So
let
me
just
yeah,
I
guess
I'm
interested
to
see
what
it
looks
like
because
I
I
feel
like
the
finders
yeah,
there's
quite
a
few
of
them
more
than
I
realized
there's.
Actually
I
don't
remember
how
many
finders.
C
B
C
How
cool
to
be
me,
and
maybe-
and
so
even
looking
at
this,
I'm
just
I'm
in
brainstorming
mode,
so
it's
like
this.
It's
probably
this
might
be
really
bad
ideas.
How
cool
would
it
be
if,
instead
of
just
contacts
finder,
which
has
a
flag,
are
we
doing
counts
or
not,
and
that
adds
to
the
complexity?
C
C
C
It's
a
little
bit
of
a
code
smell
when
you
have
the
same
function
returns
different
things
based
on
a
flag
like
that's
a
maybe
maybe
polymorphism
is
the
is
the
appropriate
approach,
but
when
we
have
one
of
these
for
every
kind
of
model
like
I
understand
the
desire
to
not
want
to
create
contacts,
count
finder
contacts,
item
finder,
like
that's
gonna,
be
way
too
much.
But
if
we're
solving
the
same
problem
for
every
model,
I'm
oversimplifying
this
I
know
I
am
so.
A
So
the
the
one
thing
and
I
felt
like
maybe
I
could
see
that
thought
in
alexandria's
head
there
when
you
were
talking
paul-
is
that
I
think
there
probably
are.
A
I'm
gonna
say
that
I
I
think
there
are
always
going
to
be
some
specifics
in
the
finders,
although
I'm
not
sure
you
were
necessarily
saying,
but
they
wouldn't
be,
but
you
know
the-
and
this
is
a
perfect
example,
because
we've
immediately
got
this
check.
That
probably
doesn't
happen
for
many
if
any
other
finders,
and
that
contacts
only
exist
on
route
groups
and
then
some
other
quite
good
examples
is
that
the
search-
although
that's
something
that's
then
implemented,
I
presume
yeah
on
here-
is
then
a
fuzzy
search,
so
you've
got
fuzzy
searches
versus
non-fuzzy
searches,.
C
So
you
could
like
put
those
specifics
inside
the
model,
the
other.
You
know
I
think,
adopting
looking
at
patterns
here
like.
C
D
Not
necessarily,
but
like
the
strategy
product
will
probably
not
solve
it
all,
because
then
you
need
to
pick
one
strategy
and
and
a
lot
of
the
times
all
these
finders
do
combine
multiple
strategies
in
that
context,
where
you
want
to
filter
by
something
and
also
search
by
something
and
also
to
sort
by
something,
and
then
also
do
some
counts,
because
it
basically
does
the
same
thing.
It
just
applies
a
count,
but
when
you
apply
account,
you
don't
need
the
order
by
because
there.
B
D
Ads
as
performances
on
a
performance
hit
on
the
database
and
so
on
and
so
forth,
so
I
mean
we
can
definitely
do
something
gradually
that
that
removes
some
of
these
repetitive
patterns
that
are
easy
to
replace
right
away.
D
So
yeah,
that's
that's
something
I
I
guess
the
thing
is
nobody
really
took
time
to
to
do
that
because
everyone
was
really
busy
with
their
own
stuff
but
yeah.
That's
that's
something
we
can
work
on.
C
That's
gonna
do
some
damage
to
the
code
base,
so
the
other
idea,
if,
if
we
can't
find
a
simple
abstraction
that
we
like
abstracting
the
tests,
because
that's
the
other
side
of
duplicate
code-
that's
really
frustrating
is
we
have
to
duplicate
all
the
unit
tests
for
whatever
unit
we're
making,
but
if
we
can,
if
we
can
then
create
if
we're
creating
multiple
versions
of
the
same
thing
that
follow
the
same
interface,
it
would
be
interesting
to
see
if
we
could
even
duplicate
or
encapsulate
how
we
test
the
thing,
because.
D
C
B
Made
me
think
of
okay,
something
with
the
sidekick
workers
cause
we
kind
of
implemented
these,
like
top
of
the
file
like
almost
like
annotations,
the
workers
have
them
and
we
have
tests
that
kind
of
test
them.
B
Our
advanced
search
migrations.
Have
them
too.
Let
me
see
if
I
can
figure
out
what
code
we
use
for
that.
Let
me
go
in
my
browser
hold
on
there.
A
Is
this
is
really
interesting?
Actually,
because
you
know
I've
written
most
of
the
code
to
get
this
this
working
and.
A
I
haven't
started
writing
the
tests
yet
and
what?
What
like
I,
I
am
dreading
it,
because
I've
got
to
figure
out,
obviously
what
we
should
test
and
what
we
shouldn't,
but
certainly
having
introduced
all
of
these
scopes
and
this
method,
which
my
terminology
is
going
to
be
wrong,
but
has
lots
of
branches
all
of
a
sudden
makes
me
think.
Am
I
seriously
going
to
have
to
write?
A
I
don't
know
what
this
is
like
20
test
cases
for
this
single
method
before
I
even
then
start
to
say
well,
you
know
this
is
then
called
by
finder,
which
is
then
called
by
graphql
resolver,
which-
and
you
know
this-
this
could
quite
easily.
You
know
double
the
amount
of
code,
if
not
more,
I'm
gonna
have
to
write
just
to
test
which,
under
the
hood,
this
is
just
well,
I
don't
know
scope.
A
So
what
do
you
call
them
like
a
an
out
of
the
box
feature,
but
because
we've
put
this
crazy
thing
on
top
of
it,
but,
like
you
said
earlier,
I
think
if
we
could
just
define
this
as
an
array
of
supported
fields
to
sort
on
or
something
along
those
lines,
then
all
of
a
sudden.
A
A
And
I
I
think
that
this,
in
my
eyes
is
maybe
the
simplest
bit
that
we
could
start
by
simplifying
simplest
bit.
We
can
simplify
the
the
the
least
contentious
sort
of
like
yeah,
most
clearly
repetitive,
undry
thing
that
we're
doing
here,
the
the
counting
and
some
of
the
foundry
stuff
etc
is
a
bit
more
of
a
hana
worms
like
I
think,
there'll
be
a
lot
of
opinionation
or
whatever.
The
term
is
a
lot
of
different
approaches,
but
but
this
seems
like
something
that
I
I
even
felt
like.
A
We've
probably
already
done
it
somewhere,
but
I
just
don't
know
the
what
you
call
it
the
grep
foo
or
whatever,
to
to
find
what
pattern
we've
maybe
implemented
somewhere
else
already.
C
C
When
we
get
a
symbol,
a
first
name
ask
then
we
do
the
order
of
the
thing
like
does
that:
okay.
A
D
The
problem
for
me
is
what
we
get
in
the
order,
because
we
got
like
first
time
ask
if
we
can
get
two
problems
here.
We
can
simplify
these
two
by
quite
a
bit,
as
you
suggested,
by
passing
in
the
attribute
by
which
you
want
to
to
sort
and
the
direction
ascending
or
descending
right.
So.
D
Yeah
now,
if
that
value,
you
can
pass
it
on
to
order
by
then
in
the
method,
in
the
model.
A
D
D
D
C
I
mean,
is
it
man
I
can't?
I
can
can't
help
myself
is.
B
C
D
Yeah,
that's
what
I
was
suggesting.
I
think
as
creating
some
sort
of
a.
I
don't
remember
how
rails
calls
it,
but.
D
D
C
Okay,
yeah
having
a
sortable
feels
things
looks
cool
and
it's
it's
not.
You
know
it.
It
wouldn't
be
that
complex
to
do
the
the
one
that
needs.
The
include
right,
like
that's
just
a.
A
A
Find
where
that
magic
is,
I've
definitely
seen
it
before.
C
B
A
A
D
Is
something
even
in
in
our
gitlab
code
base,
but.
D
A
A
And
so
yeah
we
would
define
an
array
of
kind
of
sortable
fields
to
automatically
define
the
scopes.
D
B
A
D
A
D
A
A
That
sounds
sounds
really
good.
I'm
just
wondering,
then,
the
the
next
small
sort
of
step
in
terms
of
then
cutting
out
this
middleman.
So
do
we
think
we
would
probably
create
the
scopes
with
the
same
sort
of
scientex.
So
it's
what's
the
field
name
underscore.
What's
the
direction.
A
Now
I
remember
seeing
there's
something
that
again,
I
don't
think
we
allow.
I
think
it
might
be
for
security
reasons,
the
way
that
you
would
then,
if
I
was
past
an
array
that
contains.
D
Actually,
you
don't
even
need
that
right
because
then
you
can
pass
in.
You
can
basically
create
just
two,
whether
by
ascending
and
then
passing
the
field
name.
D
It's
not
important
perspective,
but
you
need
it
in
place
to
generate
this
sequel.
So
you,
you
kind
of
need
to
let
the
model
know
what
for
for
what
thing
you
want
you
to
generate
the
sequel
but
yeah.
If
you
go
with
this
approach,
if
I
order
scope,
then
you
basically
don't
even
need
to
to
know
which
columns
you
want
to
order
by,
because
you
can
then
call
that
from
the
finder
the
finder
will
decide
which
ones
I
want
to
where
they're
buying.
A
C
I
I
feel
like
we
can
create
a
a
class
method
that
generates
these
scopes.
Oh
man,
I'm
feeling
it
so
much.
We
can
do
this.
C
A
Why
aren't
we
what
I
guess
I
would
I
don't
know
what
gets
me
what
I
like
about
this
is
it's
clear
and
wherever
you
call
it,
you
would
be
calling
it
like
this.
A
If
we
created
some
magic
method
that
created
all
of
these
scopes,
that's
where
I
get
ruby,
blackmagic
kind
of
frustrates
me
when
I
see
something
that
I'm
like.
I
can't
can't
do
death
blah.
If
you
know
what
I
mean,
I
can't
find
where
this
is
defined.
So
then
I
have
to
again
that's
that's
fair.
As
a
newbie.
B
D
So
yeah,
let's
do
the
order,
scope
but
again,
filter
by
order
by
I'm
trying
to
think
of
a
name.
But
let's
go
with
the
order
scope
for
now
and
then
then
you
want
in
the
order
you
basically
I
think
you
want
a
rel
table
so
in
the
implementation
already
yeah.
I
think
you
want
something
like
a
real
underscore
table.
D
D
D
B
B
D
B
So
there
is
an
select
from
so
it
doesn't
like
that.
A
D
D
A
A
C
B
D
B
A
D
D
C
B
B
C
A
Well,
I
was
singing
your
praises
earlier
david
on
the
thing
that
I
copied
tagged
you
in
the
other
day
about
your
alternative.
Awesome,
paginated,
tab
search.
What's
it
assuming
you
can
take
credit
for
that
anyway,
I'm
not
sure
if
somebody
else
did
all
the.
B
A
I
think
it's
a
step
in
the
right
direction:
right,
yeah,
one
small
iteration
on
the
bigger
assuming
nobody
kind
of
shouts
and
says:
oh
no,
that's
not
good,
because
I
should
hard
code
the
list
of
available
so.
C
A
C
A
Yeah
so
yeah,
so
so
this
is
very
prone
to
do.
They
call
it
copy
pasta
or
you
know
I
I
copied
this
line
and
I
forgot
to
change
the
ask
to
a
desk
and
therefore
I
should
really
write
a
test
case
for
all
of
these,
but
this
kind
of
avoids
that
potential
concern
right.
So
all
of
a
sudden,
I
don't
really
need
to
write
tests
for
all
of
these
different.
A
A
A
nice
dress,
then
awesome
consciously
everyone's
time.
Super
helpful
as
always,
and.