登录 注册

groupdate

去点 Star
数据分析与数据处理AI 模型与开发框架自动化与工作流
3,886
Stars
240
Forks
42
Watchers
3
Open Issues
MIT
许可证
Ruby
语言
2013-04-18
创建时间
2026-11-06
最近更新

项目能做什么

极简的时间维度数据分组统计方案。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Groupdate

The simplest way to group by:

- day
- week
- hour of the day
- and more (complete list below)

:tada: Time zones - including daylight saving time - supported!! **the best part**

:cake: Get the entire series - **the other best part**

Supports PostgreSQL, MySQL, MariaDB, SQLite, and Redshift, plus arrays and hashes

:cupid: Goes hand in hand with [Chartkick](https://www.chartkick.com)

[![Build Status](https://github.com/ankane/groupdate/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/groupdate/actions)

## Installation

Add this line to your application’s Gemfile:

```ruby
gem "groupdate"
```

For MySQL and MariaDB, also follow [these instructions](#additional-instructions).

## Getting Started

```ruby
User.group_by_day(:created_at).count
# {
#   Thu, 01 Jan 2026 => 50,
#   Fri, 02 Jan 2026 => 100,
#   Sat, 03 Jan 2026 => 34
# }
```

Results are returned in ascending order by default, so no need to sort.

You can group by:

- second
- minute
- hour
- day
- week
- month
- quarter
- year

and

- minute_of_hour
- hour_of_day
- day_of_week (Sunday = 0, Monday = 1, etc)
- day_of_month
- day_of_year
- month_of_year

Use it anywhere you can use `group`. Works with `count`, `sum`, `minimum`, `maximum`, and `average`. For `median` and `percentile`, check out [ActiveMedian](https://github.com/ankane/active_median).

### Time Zones

The default time zone is `Time.zone`.  Change this with:

```ruby
Groupdate.time_zone = "Pacific Time (US & Canada)"
```

or

```ruby
User.group_by_week(:created_at, time_zone: "Pacific Time (US & Canada)").count
# {
#   Sun, 04 Jan 2026 => 70,
#   Sun, 11 Jan 2026 => 54,
#   Sun, 18 Jan 2026 => 80
# }
```

Time zone objects also work. To see a list of available time zones in Rails, run `rake time:zones:all`.

### Week Start

Weeks start on Sunday by default. Change this with:

```ruby
Groupdate.week_start = :monday
```

or

```ruby
User.group_by_week(:created_at, week_start: :monday).count
```

### Day Start

You can change the hour days start with:

```ruby
Groupdate.day_start = 2 # 2 am - 2 am
```

or

```ruby
User.group_by_day(:created_at, day_start: 2).count
```

### Time Range

To get a specific time range, use:

```ruby
User.group_by_day(:created_at, range: 2.weeks.ago.midnight..Time.now).count
```

To expand the range to the start and end of the time period, use:

```ruby
User.group_by_day(:created_at, range: 2.weeks.ago..Time.now, expand_range: true).count
```

To get the most recent time periods, use:

```ruby
User.group_by_week(:created_at, last: 8).count # last 8 weeks
```

To exclude the current period, use:

```ruby
User.group_by_week(:created_at, last: 8, current: false).count
```

### Order

You can order in descending order with:

```ruby
User.group_by_day(:created_at, reverse: true).count
```

### Keys

Keys are returned as date or time objects for the start of the period.

To get keys in a different format, use:

```ruby
User.group_by_month(:created_at, format: "%b %Y").count
阅读完整原文

商业机会分析 AI 生成

Rails 商业级指标看板与报表套件(Pro Gem)

产品构想在 Groupdate 和 Chartkick 的基础上,封装开箱即用的企业级后台指标中心,提供多租户隔离、指标聚合缓存/预计算、数据导出和权限管理功能,采用商业源码授权模式售卖。
核心功能开箱即用的多时区可视化图表组件、后台异步增量统计与缓存策略、跨模型复杂指标计算、CSV/PDF 导出引擎。
目标用户需要快速为客户或管理层提供时序报表但缺乏专门 BI 团队的 Rails SaaS 初创团队。
难度/周期中等 · 2 - 3 个月 · 成本:开发机器与少量测试数据库实例,主要为人力开发时间。
收费模式按项目买断制商业 License 授权(如每应用 $199 - $499)或年度维护更新订阅。
竞争风险开源生态内存在较多平替(如自行用 Sidekiq + Redis 实现缓存),市场受限于 Ruby 生态体量。
依据 AI推测

跨数据库时序聚合与 Gap-Filling SQL 生成器 API / 服务

产品构想将 Groupdate 核心的时区处理、夏令时纠偏和时序补零(Gap-filling)逻辑解耦为跨语言的微服务或查询生成 API,支持 Python/Node/Go 等非 Ruby 生态。
核心功能支持 PostgreSQL/MySQL/SQLite/Redshift 的方言转换、任意颗粒度时序补齐参数配置、REST API 及客户端 SDK。
目标用户构建低代码平台、自定义报表系统或内部 BI 系统的全栈开发者与前端工程师。
难度/周期较低 · 1 - 2 个月 · 成本:轻量级云函数/API 网关部署成本,每月预计 < $50。
收费模式免费额度 + 按 API 调用次数梯度收费(如 $10/月 起)。
竞争风险现代数据库(如 PG 的 generate_series 或专用时序库)原生能力逐渐增强,通用型 API 需求壁垒较低。
依据 尚需验证的假设

大规模时间序列聚合查询性能优化与物化视图管理插件

产品构想针对 Groupdate 在千万级数据下直接查询导致的慢 SQL 痛点,开发自动化物化视图(Materialized Views)与增量刷新管理的 Rails 增强插件。
核心功能自动分析 Groupdate 查询模式并生成最优索引/物化视图、后台无锁增量刷新机制、透明路由代理(小查询走原表,历史大查询走聚合视图)。
目标用户业务规模扩大、后台时间聚合查询出现性能瓶颈的成长型 Rails 企业。
难度/周期较高 · 3 - 5 个月 · 成本:高并发/大数据量测试环境搭建,云数据库测试成本每月约 $100 - $300。
收费模式企业版订阅服务($49 - $199/月),或高阶技术咨询/调优打包服务。
竞争风险技术复杂度高,深度绑定特定数据库底层特性,维护成本高。
依据 数据支持的判断
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
ankane/groupdate.sql 中文介绍暂未生成
The simplest way to group temporal data
286 PLpgSQL
codesnik/calculate-all 中文介绍暂未生成
calculate_all method for aggregate functions in Active Recor
137 Ruby
mit-teaching-systems-lab/groupdate 中文介绍暂未生成
An app for sharing thoughts in larger groups, skimming them
2 JavaScript
maxwell/rails4_will_paginate_groupdate_warnings 中文介绍暂未生成
demonstrates that using both of these gems give you deprecat
2 Ruby
gorails-screencasts/gorails-episode-194 中文介绍暂未生成
Charts with Chartkick and Groupdate
1 Ruby
pettersj/groupdate 中文介绍暂未生成
1 Ruby
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2013-04-18,近 30 天仍在推送
社区活跃Star 3,886 / Fork 240 / Issue 3(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/ankane/groupdate.git
cd groupdate
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。