百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

active_median

> 编程语言
开源

活动记录、Mongoid、阵列和散列的中位数和百分数

474 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

活动记录、Mongoid、阵列和散列的中位数和百分数

ActiveMedian

Median and percentile for Active Record, Mongoid, arrays, and hashes

Supports:

  • PostgreSQL
  • SQLite
  • MariaDB
  • MySQL (with an extension)
  • SQL Server
  • MongoDB

:fire: Uses native functions for blazing performance

Getting Started

Add this line to your application’s Gemfile:

ruby
gem "active_median"

For MySQL, also follow these instructions.

Models

Median

ruby
Item.median(:price)

Percentile

ruby
Request.percentile(:response_time, 0.95)

Works with grouping, too

ruby
Order.group(:store_id).median(:total)

Arrays and Hashes

Median

ruby
[1, 2, 3].median

Percentile

ruby
[1, 2, 3].percentile(0.95)

You can also pass a block

ruby
{a: 1, b: 2, c: 3}.median { |k, v| v }

Additional Instructions

MySQL

MySQL requires the PERCENTILE_CONT function from udf_infusion. To install it, do:

bash
git clone https://github.com/infusion/udf_infusion.git
cd udf_infusion
./configure --enable-functions="percentile_cont"
make
sudo make install
mysql   /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P YourStrong\!Passw0rd -C -Q "CREATE DATABASE active_median_test"
ADAPTER=sqlserver BUNDLE_GEMFILE=gemfiles/sqlserver.gemfile bundle exec rake test

# MongoDB
BUNDLE_GEMFILE=gemfiles/mongoid7.gemfile bundle exec rake test

Issues· 3 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言