Commit graph

6 commits

Author SHA1 Message Date
Jeremy Friesen
3fb085b3d9
Adding more context to /admin/abtests (#17821)
* Adding more context to `/admin/abtests`

Prior to this commit, the `/admin/abtests` was fully rendered by the
field_test gem (see
https://github.com/ankane/field_test/blob/master/app/views/field_test/experiments/index.html.erb
and
https://github.com/ankane/field_test/blob/master/app/views/field_test/experiments/show.html.erb).

With this commit, we're pre-pending our own
partial (e.g. `app/views/field_test/experiments/_experiments.html.erb`)
in the view paths; which means instead of rendering
https://github.com/ankane/field_test/blob/master/app/views/field_test/experiments/_experiments.html.erb
we render our newly created
`app/views/field_test/experiments/_experiments.html.erb`)

Why the ugly antics in the view?  As I'm not fully certain if this will
"meet" the full needs of those monitoring the experiments.  I'm also
constructing this to most closely match the spreadsheet that has been
assembled for tracking this information.

Why introduce another caching layer for the variant assembly?  The
original caching
layer (e.g. `Articles::Feeds::VariantAssembler.pre_assembled_variants`)
is in place to provide the quickest access to the assembled variants.
But due to the nature of the implemented view, we are needing a
programmatic representation of all variants.  And the added Rails cache
is there to minimize disk reads.

Closes forem/forem#17820

* Update app/models/articles/feeds/variant_assembler.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update app/models/articles/feeds/variant_assembler.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-06-03 11:27:09 -04:00
Jeremy Friesen
38ee9ef309
Refactoring so relevancy levers define expected variables (#17591)
Prior to this commit, the SQL fragments included variables that were set
configured at a global level.

With this commit, we're now saying that each lever "knows" what variable
it needs; and providing the means at lever declaration time to "say"
what those variable names are.  (e.g. `Articles::Feeds::LEVER_CATALOG`).

Then as part of the variant configuration (in the
`./config/feed-variants/*.json` files) we now include the expected value
of those parameters; which by convention (and coercion) are integers.

This relates to forem/forem#17584 because we want to move from a
privileged user reaction that has two values (`negative` and `positive`)
into four values (`very_negative`, `negative`, `positive`, and
`very_positive`).  To do that, we'll create a new lever; but that's for
another pull request.
2022-05-06 13:54:33 -04:00
Jeremy Friesen
4bc181503f
Removing WeightedQueryStrategy; use VariantQuery now (#17420)
You had a good ride, but your successor, the
`Articles::Feeds::VariantQuery`, is doing well in production.  And has
been for quite awhile.

You helped us get to a better spot in regards to the feed algorithm, but
your time has come to rest as a memory in our git history.
2022-04-27 09:19:09 -04:00
Jeremy Friesen
0d0464be2f
Allowing VariantQuery for Feed Generation (#17382)
* Allowing VariantQuery for Feed Generation

Apologies for the breadth of this pull request, I had considered many
small commits, but felt that would've been more effort for the value
provided.

This commit includes the following:

- Documentation updates to the feed variant (though not the final pass)
- Renaming and adding RelevancyLevers that help differentiate
- Adding RelevancyLever#range to provide documentation
- Reducing redundent controller logic by making a
  `Articles::Feeds.feed_for` method.
- Adding some configuration validation for RelevancyLevers
- Adding constants for better clarification
- Testing unhappy paths for feed configuration
- Adjusting the module namespace of some objects
- Exposing top-level configurations for variants (along with their
  defaults)
- Creating the VariantyQuery that at present inherits from the
  `Articles::Feeds::WeightedQueryStrategy`

As implemented, we can deploy this code to production without using the
new VariantQuery.  Once we toggle on the
`:feed_uses_variant_query_feature` FeatureFlag, it will switch to using
the VariantQuery.  The VariantQuery's two variants and the
internal configuration of `Articles::Feeds::WeightedQueryStrategy`
produce the same query.

The goal of this factor is to allow for a quick on and off toggle of the
feed query; to ensure that what we introduce remains performant.

- Closes forem/forem#17272
- Closes forem/forem#17276
- Closes forem/forem#17216

In addition, I will be recording a code-walkthrough and linking that
recording to the pull request.

* Apply suggestions from code review

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-04-21 11:07:09 -04:00
Jeremy Friesen
034ec6e3fe
Introducing the Articles::Feeds configurations (#17314)
**tl;dr** This PR is looking to provide a means to programmatically
assemble, from system configurations, what is currently the
[Articles::Feeds::WeightedQueryStrategy::SCORING_METHOD_CONFIGURATIONS][1].
Once we merge this PR, instead of having that constant, we'll initialize
the Articles::Feeds::WeightedQueryStrategy with the variant
configuration that we've assembled.

**Introduction**

This pull request has quite a bit going on, but as of now the production
code does not use any of it.

*Note: None of this code is bleeding into production code paths.*

Put your Ruby hat on and let's go for a ride.  And apologizes for not
making this a smaller pull request.  As I built this, I made many small
commits, but this became the smallest commit that provided the most
context without integrating into production code.

Before we get started, you may want to familiarize yourself with where
we're going.  The `./app/models/articles/feeds/README.md` provides
further guidance; but fair warning reader, I have not reconciled the
README's language with what emerged as I wrote this pull request.

Those of you who are part of Forem Core team, you can read the
[Refinements to Our Present Feed Configuration][2]
to provide some insight into what's happening.

**Why not reconcile?** *Because I want to have all of the language and
thoughts available for you to help consider how best to name and model
this.*

**On to the Review**

The purpose of this pull request is to provide a mechanism for
engineering to provide a series of variant query levers.  And to allow
us to easily configure those available query levers into a variant
query.

*Why the mix of Ruby configuration and JSON?*

The Ruby levers are meant to indicate that this is code we don't want to
expose in text based configuration because it might create SQL inject
points.  (More on that when we integrate the code of this PR into the
production implementation)

The JSON levers are meant to indicate that "anyone" can pick the
appropriate/available levers and configure how they are set.  In other
words, these values do not create SQL injection issues.

**What I Need from You**

I am putting this forward as a draft so you can read this code ahead of
time.  I'm then going to schedule a synchronous code review where we
record our collective walk through of the implementation.

Closes:

- forem/forem#17268
- forem/forem#17269
- forem/forem#17270
- forem/forem#17271
- forem/forem#17273

Relates to:

- forem/forem#17308
- forem/forem#17245

[1]:6818ef3ed0/app/services/articles/feeds/weighted_query_strategy.rb (L84-L231)
[2]:https://forem.team/jeremy/refinements-to-our-present-feed-configuration-1p0c
2022-04-19 16:51:18 -04:00
Jeremy Friesen
05bad3ae10
Replacing custom call with existing cached method (#16083)
There's a few things going on:

1. I introduced [a change][1].
2. There was a [data script][2] that should've completed successfully, but
   some data was not converted (see [Blazer query on DEV.to][3])

Thus the current state of the data means that we have have serialized
data in an `OpenStruct` format and `Articles::CachedEntity` format.

This patch should work because the OpenStruct should previously have an
`image_profile_90` attribute.

In addition, I have added some recommendations and tests to better
describe what's happening.

[1]:9780dba380/app/models/articles/cached_entity.rb (L4)
[2]:9780dba380/lib/data_update_scripts/20200723070918_update_articles_cached_entities.rb (L1)
[3]:https://dev.to/admin/blazer/queries/609-serialized-data-in-mixed-forms
2022-01-13 07:48:32 -05:00