Skip to content

Commit

Permalink
Merge pull request #2644 from ujh/allow-100-chars
Browse files Browse the repository at this point in the history
Allow 100 chars
  • Loading branch information
ujh authored Feb 6, 2025
2 parents 00d9424 + d0b64ec commit 1b9fbc9
Show file tree
Hide file tree
Showing 283 changed files with 909 additions and 3,081 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
6e5dbca8b246dc3bf118c55b4f5808632fb39518
27fd8fae713a01cf463ccb15096635bf38e5474e
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 80,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
Expand Down
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ gem "faraday"
gem "faraday_middleware"
gem "font-awesome-rails"
gem "google-apis-youtube_v3"
gem "gutentag",
github: "ujh/gutentag",
ref: "ded5c52ea97d1f2f4d89935d7a87d6fbaed05711"
gem "gutentag", github: "ujh/gutentag", ref: "ded5c52ea97d1f2f4d89935d7a87d6fbaed05711"
gem "honeybadger"
gem "jbuilder"
gem "jquery-rails"
Expand Down
4 changes: 1 addition & 3 deletions app/assets/javascripts/currently_inked.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
$(function () {
$(
"#currently_inked_collected_pen_id, #currently_inked_collected_ink_id"
).select2({
$("#currently_inked_collected_pen_id, #currently_inked_collected_ink_id").select2({
width: "100%"
});

Expand Down
11 changes: 3 additions & 8 deletions app/assets/javascripts/js.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@

if (typeof attributes.expires === "number") {
var expires = new Date();
expires.setMilliseconds(
expires.getMilliseconds() + attributes.expires * 864e5
);
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e5);
attributes.expires = expires;
}

// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires
? attributes.expires.toUTCString()
: "";
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : "";

try {
result = JSON.stringify(value);
Expand Down Expand Up @@ -127,8 +123,7 @@
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read
? converter.read(cookie, name)
: converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
: converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent);

if (this.json) {
try {
Expand Down
13 changes: 4 additions & 9 deletions app/assets/javascripts/sprockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
//= require_tree .

$(function () {
$(".admin-macro-cluster-row, .admin-micro-cluster-row").on(
"ajax:success",
function () {
location.reload();
}
);
$(".admin-macro-cluster-row, .admin-micro-cluster-row").on("ajax:success", function () {
location.reload();
});
});

$(function () {
Expand All @@ -48,8 +45,6 @@ $(function () {
var ink_review_submission_form = $("#new_ink_review_submission");
ink_review_submission_form.on("ajax:success", () => {
ink_review_submission_form.find("input").val("");
ink_review_submission_form
.find(".form-text")
.text("URL successful submitted!");
ink_review_submission_form.find(".form-text").text("URL successful submitted!");
});
});
11 changes: 3 additions & 8 deletions app/assets/stylesheets/sprockets-application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@
.select2-dropdown,
.select2-container--default .select2-selection--single,
.select2-container--default
.select2-results__option[aria-selected="true"]:not(
.select2-results__option--highlighted
) {
.select2-results__option[aria-selected="true"]:not(.select2-results__option--highlighted) {
background-color: var(--bs-body-bg);
border-color: var(--bs-border-color);
color: var(--fpc-text-color);
}

.select2-container--default
.select2-results__option--highlighted[aria-selected] {
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: var(--bs-primary);
border-color: var(--bs-primary-border-subtle);
color: #fff;
}

.select2-container--default
.select2-selection--single
.select2-selection__rendered {
.select2-container--default .select2-selection--single .select2-selection__rendered {
color: var(--fpc-text-color);
}

Expand Down
6 changes: 1 addition & 5 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def update
private

def accounts_params
(params["_jsonapi"] || params).require(:user).permit(
:name,
:blurb,
:time_zone
)
(params["_jsonapi"] || params).require(:user).permit(:name, :blurb, :time_zone)
end
end
3 changes: 1 addition & 2 deletions app/controllers/admins/blog_posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Admins::BlogPostsController < Admins::BaseController
def index
@blog_posts =
BlogPost.order("published_at desc, created_at desc").page(params[:page])
@blog_posts = BlogPost.order("published_at desc, created_at desc").page(params[:page])
end

def new
Expand Down
25 changes: 5 additions & 20 deletions app/controllers/admins/graphs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def show

def signups
[
{
data: build(User.active.not_spam, range: 2.months),
name: "Confirmed signups"
},
{ data: build(User.active.not_spam, range: 2.months), name: "Confirmed signups" },
{
data: build(User.where(confirmed_at: nil, bot: false), range: 2.months),
name: "Unconfirmed & not bot"
Expand All @@ -47,10 +44,7 @@ def bot_signups
.pluck(:bot_reason)
.reject { |reason| reason.blank? }
.map do |reason|
{
name: reason,
data: build(User.bots.where(bot_reason: reason), range: 2.months)
}
{ name: reason, data: build(User.bots.where(bot_reason: reason), range: 2.months) }
end
end

Expand All @@ -62,10 +56,7 @@ def spam
.pluck(:spam_reason)
.reject { |reason| reason.blank? }
.map do |reason|
{
name: reason,
data: build(User.where(spam_reason: reason), range: 2.months)
}
{ name: reason, data: build(User.where(spam_reason: reason), range: 2.months) }
end
end

Expand All @@ -84,11 +75,7 @@ def user_agents
.where(name: name)
.group("date_trunc('hour', created_at)")
.order("hour asc")
.pluck(
Arel.sql(
"date_trunc('hour', created_at) as hour, count(*) as hour_count"
)
)
.pluck(Arel.sql("date_trunc('hour', created_at) as hour, count(*) as hour_count"))
.map { |d| [d.first.to_i * 1000, d.last] }
}
end
Expand Down Expand Up @@ -116,9 +103,7 @@ def build(base_relation, range: 1.year)
.where("created_at > ?", range.ago)
.group("date_trunc('day', created_at)")
.order("day asc")
.pluck(
Arel.sql("date_trunc('day', created_at) as day, count(*) as day_count")
)
.pluck(Arel.sql("date_trunc('day', created_at) as day, count(*) as day_count"))
.map { |d| [d.first.to_i * 1000, d.last] }
end
end
24 changes: 3 additions & 21 deletions app/controllers/admins/macro_clusters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ def index

def show
cluster = MacroCluster.find(params[:id])
render json:
MacroClusterSerializer
.new(cluster, show_options)
.serializable_hash
.to_json
render json: MacroClusterSerializer.new(cluster, show_options).serializable_hash.to_json
end

def create
Expand Down Expand Up @@ -61,14 +57,7 @@ def index_options(rel)
{
include: %i[micro_clusters micro_clusters.collected_inks],
fields: {
collected_ink: %i[
brand_name
line_name
ink_name
maker
color
micro_cluster
],
collected_ink: %i[brand_name line_name ink_name maker color micro_cluster],
micro_cluster: %i[collected_inks macro_cluster]
},
meta: {
Expand All @@ -81,14 +70,7 @@ def show_options
{
include: %i[micro_clusters micro_clusters.collected_inks],
fields: {
collected_ink: %i[
brand_name
line_name
ink_name
maker
color
micro_cluster
]
collected_ink: %i[brand_name line_name ink_name maker color micro_cluster]
}
}
end
Expand Down
34 changes: 5 additions & 29 deletions app/controllers/admins/micro_clusters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ def index
clusters =
MicroCluster
.includes(:collected_inks)
.order(
:simplified_brand_name,
:simplified_line_name,
:simplified_ink_name
)
.order(:simplified_brand_name, :simplified_line_name, :simplified_ink_name)
.page(params[:page])
clusters = clusters.unassigned if params[:unassigned]
clusters = clusters.without_ignored if params[:without_ignored]
Expand All @@ -30,9 +26,7 @@ def ignored
.joins(:collected_inks)
.select("micro_clusters.*, count(*) as count")
.group("micro_clusters.id")
.order(
"count desc, simplified_brand_name, simplified_line_name, simplified_ink_name"
)
.order("count desc, simplified_brand_name, simplified_line_name, simplified_ink_name")
end

def update
Expand All @@ -42,11 +36,7 @@ def update
if request.referrer == ignored_admins_micro_clusters_url
redirect_to ignored_admins_micro_clusters_url
else
render json:
MicroClusterSerializer
.new(cluster, update_options)
.serializable_hash
.to_json
render json: MicroClusterSerializer.new(cluster, update_options).serializable_hash.to_json
end
end

Expand All @@ -70,14 +60,7 @@ def index_options(rel)
{
include: [:collected_inks],
fields: {
collected_ink: %i[
brand_name
line_name
ink_name
maker
color
micro_cluster
]
collected_ink: %i[brand_name line_name ink_name maker color micro_cluster]
},
meta: {
pagination: pagination(rel)
Expand All @@ -89,14 +72,7 @@ def update_options
{
include: %i[collected_inks macro_cluster],
fields: {
collected_ink: %i[
brand_name
line_name
ink_name
maker
color
micro_cluster
]
collected_ink: %i[brand_name line_name ink_name maker color micro_cluster]
}
}
end
Expand Down
45 changes: 7 additions & 38 deletions app/controllers/admins/pens/micro_clusters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ def index
# FIXME: Adding an includes here breaks the serialization and does not include
# the collected pens anymore. This is due to the way the association is
# set up and not being really bi-directional.
clusters =
Pens::MicroCluster
.includes(:collected_pens)
.ordered
.page(params[:page])
clusters = Pens::MicroCluster.includes(:collected_pens).ordered.page(params[:page])
if params[:count]
clusters =
clusters
Expand Down Expand Up @@ -38,54 +34,35 @@ def ignored
.joins(:collected_pens)
.select("pens_micro_clusters.*, count(*) as count")
.group("pens_micro_clusters.id")
.order(
"count desc, simplified_brand, simplified_model, simplified_color"
)
.order("count desc, simplified_brand, simplified_model, simplified_color")
end

def update
cluster = Pens::MicroCluster.find(params[:id])
cluster.update!(update_params)
Pens::UpdateMicroCluster.perform_async(cluster.id)
render json:
PensMicroClusterSerializer
.new(cluster, update_options)
.serializable_hash
.to_json
render json: PensMicroClusterSerializer.new(cluster, update_options).serializable_hash.to_json
end

def unassign
cluster = Pens::MicroCluster.find(params[:id])
model_variant_id = cluster.pens_model_variant_id
cluster.update!(pens_model_variant_id: nil)
if model_variant_id.present?
Pens::UpdateModelVariant.perform_async(model_variant_id)
end
Pens::UpdateModelVariant.perform_async(model_variant_id) if model_variant_id.present?
redirect_to(request.referrer || admins_pens_model_variants_path)
end

private

def update_params
(params["_jsonapi"] || params).dig(:data, :attributes).permit(
:ignored,
:pens_model_variant_id
)
(params["_jsonapi"] || params).dig(:data, :attributes).permit(:ignored, :pens_model_variant_id)
end

def update_options
{
include: %i[collected_pens model_variant],
fields: {
collected_pen: %i[
brand
model
color
material
trim_color
filling_system
pens_micro_cluster
]
collected_pen: %i[brand model color material trim_color filling_system pens_micro_cluster]
}
}
end
Expand All @@ -94,15 +71,7 @@ def index_options(rel)
{
include: [:collected_pens],
fields: {
collected_pen: %i[
brand
model
color
material
trim_color
filling_system
pens_micro_cluster
]
collected_pen: %i[brand model color material trim_color filling_system pens_micro_cluster]
},
meta: {
pagination: pagination(rel)
Expand Down
Loading

0 comments on commit 1b9fbc9

Please sign in to comment.