forked from Gitlink/forgeplus
每日统计
This commit is contained in:
parent
aa81e7030d
commit
2a02b6f530
|
@ -1,3 +1,24 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: public_key
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# owner_id :integer not null
|
||||||
|
# name :string(255) not null
|
||||||
|
# fingerprint :string(255) not null
|
||||||
|
# content :text(65535) not null
|
||||||
|
# mode :integer default("2"), not null
|
||||||
|
# type :integer default("1"), not null
|
||||||
|
# login_source_id :integer default("0"), not null
|
||||||
|
# created_unix :integer
|
||||||
|
# updated_unix :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# IDX_public_key_fingerprint (fingerprint)
|
||||||
|
# IDX_public_key_owner_id (owner_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Gitea::PublicKey < Gitea::Base
|
class Gitea::PublicKey < Gitea::Base
|
||||||
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
|
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
|
||||||
# establish_connection :gitea_db
|
# establish_connection :gitea_db
|
||||||
|
|
|
@ -1,3 +1,34 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: webhook
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# repo_id :integer
|
||||||
|
# org_id :integer
|
||||||
|
# url :text(65535)
|
||||||
|
# signature :text(65535)
|
||||||
|
# http_method :string(255)
|
||||||
|
# content_type :integer
|
||||||
|
# secret :text(65535)
|
||||||
|
# events :text(65535)
|
||||||
|
# is_ssl :boolean
|
||||||
|
# is_active :boolean
|
||||||
|
# hook_task_type :integer
|
||||||
|
# meta :text(65535)
|
||||||
|
# last_status :integer
|
||||||
|
# created_unix :integer
|
||||||
|
# updated_unix :integer
|
||||||
|
# is_system_webhook :boolean default("0"), not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# IDX_webhook_created_unix (created_unix)
|
||||||
|
# IDX_webhook_is_active (is_active)
|
||||||
|
# IDX_webhook_org_id (org_id)
|
||||||
|
# IDX_webhook_repo_id (repo_id)
|
||||||
|
# IDX_webhook_updated_unix (updated_unix)
|
||||||
|
#
|
||||||
|
|
||||||
class Gitea::Webhook < Gitea::Base
|
class Gitea::Webhook < Gitea::Base
|
||||||
serialize :events, JSON
|
serialize :events, JSON
|
||||||
self.inheritance_column = nil
|
self.inheritance_column = nil
|
||||||
|
@ -10,4 +41,4 @@ class Gitea::Webhook < Gitea::Base
|
||||||
enum hook_task_type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
|
enum hook_task_type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
|
||||||
enum last_status: {waiting: 0, succeed: 1, fail: 2}
|
enum last_status: {waiting: 0, succeed: 1, fail: 2}
|
||||||
enum content_type: {json: 1, form: 2}
|
enum content_type: {json: 1, form: 2}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: hook_task
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# repo_id :integer
|
||||||
|
# hook_id :integer
|
||||||
|
# uuid :string(255)
|
||||||
|
# type :integer
|
||||||
|
# url :text(65535)
|
||||||
|
# signature :text(65535)
|
||||||
|
# payload_content :text(65535)
|
||||||
|
# http_method :string(255)
|
||||||
|
# content_type :integer
|
||||||
|
# event_type :string(255)
|
||||||
|
# is_ssl :boolean
|
||||||
|
# is_delivered :boolean
|
||||||
|
# delivered :integer
|
||||||
|
# is_succeed :boolean
|
||||||
|
# request_content :text(65535)
|
||||||
|
# response_content :text(65535)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# IDX_hook_task_repo_id (repo_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Gitea::WebhookTask < Gitea::Base
|
class Gitea::WebhookTask < Gitea::Base
|
||||||
serialize :payload_content, JSON
|
serialize :payload_content, JSON
|
||||||
serialize :request_content, JSON
|
serialize :request_content, JSON
|
||||||
|
@ -10,4 +37,4 @@ class Gitea::WebhookTask < Gitea::Base
|
||||||
belongs_to :webhook, class_name: "Gitea::Webhook", foreign_key: :hook_id
|
belongs_to :webhook, class_name: "Gitea::Webhook", foreign_key: :hook_id
|
||||||
|
|
||||||
enum type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
|
enum type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: statistics
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# dau :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
|
||||||
|
class Statistic < ApplicationRecord
|
||||||
|
def self.record
|
||||||
|
users = User.all
|
||||||
|
count = 0
|
||||||
|
t = Time.now - 1.day
|
||||||
|
# t = Time.now.at_beginning_of_day
|
||||||
|
users.each do |u|
|
||||||
|
if !u.last_login_on.nil? && u.last_login_on >= t
|
||||||
|
count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Statistic.create(dau: count)
|
||||||
|
end
|
||||||
|
end
|
|
@ -23,6 +23,9 @@ set :environment, :development
|
||||||
every '0 1 20 * *' do
|
every '0 1 20 * *' do
|
||||||
runner 'Sponsorship.monthly_payment'
|
runner 'Sponsorship.monthly_payment'
|
||||||
end
|
end
|
||||||
|
every '0 2 * * *' do
|
||||||
|
runner 'Statistic.record'
|
||||||
|
end
|
||||||
# every 1.month, at: 'January 20th 10:00am' do
|
# every 1.month, at: 'January 20th 10:00am' do
|
||||||
# runner 'Sponsorship.monthly_payment'
|
# runner 'Sponsorship.monthly_payment'
|
||||||
# end
|
# end
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateStatistics < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :statistics do |t|
|
||||||
|
t.integer :dau
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Statistic, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue