-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formula_json: compress markup into for loops, add analytics-linux
and fix "full_full_name" typo
- Loading branch information
1 parent
8ff68c1
commit c4152e8
Showing
1 changed file
with
33 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,46 @@ | ||
--- | ||
--- | ||
{%- assign formula_path = page.dir | split: "/" -%} | ||
{%- assign formula_path = formula_path[2] -%} | ||
{%- if formula_path == "formula-linux" -%} | ||
{%- assign analytics_path = "analytics-linux" -%} | ||
{%- assign analytics_data_source = "linuxbrew-core" -%} | ||
{%- else -%} | ||
{%- assign analytics_path = "analytics" -%} | ||
{%- assign analytics_data_source = "homebrew-core" -%} | ||
{%- endif -%} | ||
{%- assign full_name = page.name | remove: ".json" -%} | ||
{%- assign name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%} | ||
{%- assign formula = site.data[formula_path][name] -%} | ||
{%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%} | ||
{%- assign formula = site.data.formula[data_name] -%} | ||
{%- assign sources = "analytics, analytics-linux" | split: ", " -%} | ||
{%- assign categories = "install, install-on-request, build-error" | split: ", " -%} | ||
{%- assign intervals = "30d, 90d, 365d" | split: ", " -%} | ||
{ | ||
|
||
{%- for key_value in formula -%} | ||
{{ key_value[0] | jsonify }}:{{ key_value[1] | jsonify }}, | ||
{%- endfor -%} | ||
|
||
"analytics":{"install":{"30d":{ | ||
{%- if site.data[analytics_path].install[analytics_data_source]["30d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install[analytics_data_source]["30d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- for source in sources -%} | ||
"{{ source }}":{ | ||
{%- for category in categories -%} | ||
"{{ category | replace: "-", "_" }}":{ | ||
{%- for interval in intervals -%} | ||
"{{ interval }}":{ | ||
{%- if site.data[source][category].homebrew-core[interval].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[source][category].homebrew-core[interval].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
} | ||
{%- if category == "build-error" -%} | ||
{%- break -%} | ||
{%- endif -%} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
},"90d":{ | ||
|
||
{%- if site.data[analytics_path].install[analytics_data_source]["90d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install[analytics_data_source]["90d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
},"365d":{ | ||
|
||
{%- if site.data[analytics_path].install[analytics_data_source]["365d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install[analytics_data_source]["365d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
}},"install_on_request":{"30d":{ | ||
|
||
{%- if site.data[analytics_path].install-on-request[analytics_data_source]["30d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install-on-request[analytics_data_source]["30d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
},"90d":{ | ||
|
||
{%- if site.data[analytics_path].install-on-request[analytics_data_source]["90d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install-on-request[analytics_data_source]["90d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
},"365d":{ | ||
|
||
{%- if site.data[analytics_path].install-on-request[analytics_data_source]["365d"].formulae[full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].install-on-request[analytics_data_source]["365d"].formulae[full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
}},"build_error":{"30d":{ | ||
|
||
{%- if site.data[analytics_path].build-error[analytics_data_source]["30d"].formulae[full_full_name].size > 0 -%} | ||
{%- for fa in site.data[analytics_path].build-error[analytics_data_source]["30d"].formulae[full_full_name] -%} | ||
{{ fa.formula | jsonify }}:{{ fa.count | remove: "," | plus: 0 }} | ||
{%- unless forloop.last -%} | ||
, | ||
{%- endunless -%} | ||
{%- endfor -%} | ||
{%- else -%} | ||
{{ full_name | jsonify }}:0 | ||
{%- endif -%} | ||
}}},"generated_date":"{{ "today" | date: "%F" }}"} | ||
}, | ||
{%- endfor -%} | ||
"generated_date":"{{ "today" | date: "%F" }}"} |