Skip to content

Recompilation speedup: break out Pleroma.Web.Params.truthy_param?/1 from ControllerHelper

Alex Gleason requested to merge cycles-params into develop

#2651 (closed)

In web browsers, the value of an HTML checkbox input is usually "on" or "off" (a string) rather than true/false. This can pose a problem for backend servers who need to then interpret boolean params in a request.

The function ControllerHelper.truthy_param?/1 exists to convert boolean params from browsers into native Elixir booleans true/false.

However, this function is used by more than just controllers. When used by ApiSpec.Schemas.BooleanLike, it creates a cycle on Pleroma.Web (use'd by ControllerHelper).

For a simple function with no dependencies, it's better off in its own module, so I created Pleroma.Web.Params for it. And now its purpose is more clear when used outside of controller modules.

This gets rid of a cycle and reduces most others: https://www.diffchecker.com/CqMAcUcO

Screenshot_from_2021-06-07_13-56-26

Merge request reports

Loading