timingapp 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a79de69ccb24a1e5c35a69207a219f1fe55b45ed4235b9754672d0092d7810d
4
- data.tar.gz: 6c231d00516bf4fa9e6469e2dc845993ad36403fddd5fa791c8981b890b4cae6
3
+ metadata.gz: 0bbf343e9db9ad0a5cc47973b64324a5f8f2db9c4c212c506d685bb1012ca142
4
+ data.tar.gz: 385f3dfb6c8b4443cae10f63980c44dfe2da09b3068f3f76795ce4ef8b6e71ae
5
5
  SHA512:
6
- metadata.gz: a7534b16516f60eaa05099ce33fc7462692228d447e11dafd02cedc25f80a9ab2bfef349c1cead89c0ceab8da578c68a68bfcf4a2d4431c7915f55a23bacf24b
7
- data.tar.gz: 8ed80e54333c6dcdcb8c313e36ebed9592ba35eb075b4f9c9bf121f7780a0b078c9b2a603f4c6b882bc0baacc8384300d5dc96889d822a403313fcbf303e023e
6
+ metadata.gz: 62e1b5c1ff904701269431b8c0b9940bf2cc03342ee1af63a0d9e3a514c236382854e6ba73831cacf130608bd27f089bb5e745dfaadea0de1b704c03e6628ec6
7
+ data.tar.gz: 680a1c4eba43e5d67a99d6aa74855380bbfbd1d2f3239b7b47cf95d7d861b96095b3075c9c9c18cbdf82c73a46bd118dcd3fab316e89b1d4751e9899c69b162e
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.1
2
+ TargetRubyVersion: 3.2
3
3
  NewCops: enable
4
4
  SuggestExtensions: false
5
5
 
@@ -12,6 +12,10 @@ Style/StringLiteralsInInterpolation:
12
12
  Style/Documentation:
13
13
  Enabled: false
14
14
 
15
+ Naming/PredicateName:
16
+ Exclude:
17
+ - lib/timingapp/timing_record.rb
18
+
15
19
  Naming/MethodName:
16
20
  Exclude:
17
21
  - lib/timingapp/models/**
@@ -5,18 +5,15 @@ module Timingapp
5
5
  self.table_name = "AppActivity"
6
6
  self.primary_key = "id"
7
7
 
8
- belongs_to :application, foreign_key: "applicationID"
9
- belongs_to :localDevice, foreign_key: "localDeviceID", primary_key: "localID", class_name: "Timingapp::Device"
10
- belongs_to :project, foreign_key: "projectID"
11
- belongs_to :title, foreign_key: "titleID"
12
- belongs_to :path, foreign_key: "pathID"
8
+ belongs_to :device, foreign_key: :localDeviceID
9
+ belongs_to :application, foreign_key: :applicationID
10
+ belongs_to :title, foreign_key: :titleID
11
+ belongs_to :path, foreign_key: :pathID
12
+ belongs_to :project, foreign_key: :projectID
13
13
 
14
- def startDate
15
- Time.at(super)
16
- end
14
+ scope :deleted, -> { where(isDeleted: true) }
17
15
 
18
- def endDate
19
- Time.at(super)
20
- end
16
+ time_column :startDate
17
+ time_column :endDate
21
18
  end
22
19
  end
@@ -4,5 +4,16 @@ module Timingapp
4
4
  class AppActivityWithStrings < TimingRecord
5
5
  self.table_name = "AppActivityWithStrings"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :device, foreign_key: :localDeviceID
9
+ belongs_to :application, foreign_key: :applicationID
10
+ belongs_to :title, foreign_key: :titleID
11
+ belongs_to :path, foreign_key: :pathID
12
+ belongs_to :project, foreign_key: :projectID
13
+
14
+ scope :deleted, -> { where(isDeleted: true) }
15
+
16
+ time_column :startDate
17
+ time_column :endDate
7
18
  end
8
19
  end
@@ -4,5 +4,7 @@ module Timingapp
4
4
  class Application < TimingRecord
5
5
  self.table_name = "Application"
6
6
  self.primary_key = "id"
7
+
8
+ json_column :property_bag
7
9
  end
8
10
  end
@@ -3,6 +3,8 @@
3
3
  module Timingapp
4
4
  class Device < TimingRecord
5
5
  self.table_name = "Device"
6
- self.primary_key = "id"
6
+ self.primary_key = "localID"
7
+
8
+ json_column :property_bag
7
9
  end
8
10
  end
@@ -4,5 +4,16 @@ module Timingapp
4
4
  class Event < TimingRecord
5
5
  self.table_name = "Event"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :integration, foreign_key: :integration_id
9
+ belongs_to :event_source, foreign_key: :event_source_id
10
+
11
+ json_column :property_bag
12
+
13
+ time_column :start_date
14
+ time_column :end_date
15
+ time_column :last_modified_origin
16
+ time_column :last_modified_timing
17
+ time_column :deleted_at
7
18
  end
8
19
  end
@@ -4,5 +4,20 @@ module Timingapp
4
4
  class EventSource < TimingRecord
5
5
  self.table_name = "EventSource"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :integration, foreign_key: :integration_id
9
+ belongs_to :integration_project, foreign_key: :integration_project_id
10
+ belongs_to :template, foreign_key: :template_id
11
+
12
+ scope :templates, -> { where(is_template: true) }
13
+ scope :favorites, -> { where(is_favorite: true) }
14
+
15
+ time_column :last_modified_origin
16
+ time_column :last_modified_timing
17
+ time_column :created_by_integration_at
18
+ time_column :deleted_by_integration_at
19
+ time_column :hidden_at
20
+
21
+ json_column :property_bag
7
22
  end
8
23
  end
@@ -4,5 +4,16 @@ module Timingapp
4
4
  class EventSourceTaskActivity < TimingRecord
5
5
  self.table_name = "EventSourceTaskActivity"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :integration, foreign_key: :integration_id
9
+ belongs_to :event_source, foreign_key: :event_source_id
10
+ belongs_to :task_activity, foreign_key: :task_activity_id
11
+ belongs_to :event, foreign_key: :event_id
12
+
13
+ scope :deleted, -> { where.not(deleted_at: nil) }
14
+
15
+ time_column :deleted_at
16
+
17
+ json_column :property_bag
7
18
  end
8
19
  end
@@ -4,5 +4,9 @@ module Timingapp
4
4
  class Filter < TimingRecord
5
5
  self.table_name = "Filter"
6
6
  self.primary_key = "id"
7
+
8
+ has_parent
9
+
10
+ scope :samples, -> { where(isSample: true) }
7
11
  end
8
12
  end
@@ -4,5 +4,14 @@ module Timingapp
4
4
  class Integration < TimingRecord
5
5
  self.table_name = "Integration"
6
6
  self.primary_key = "id"
7
+ self.inheritance_column = nil
8
+
9
+ time_column :enabled_at
10
+ time_column :paused_at
11
+ time_column :deleted_at
12
+ time_column :last_modified_origin
13
+ time_column :last_modified_timing
14
+
15
+ json_column :property_bag
7
16
  end
8
17
  end
@@ -2,7 +2,11 @@
2
2
 
3
3
  module Timingapp
4
4
  class IntegrationLogResult < TimingRecord
5
- self.table_name = "IntegrationLogResult"
5
+ self.table_name = "integration_log_result"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :integration, foreign_key: :integration_id
9
+
10
+ time_column :timestamp
7
11
  end
8
12
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Timingapp
4
+ class IntegrationProject < TimingRecord
5
+ self.table_name = "IntegrationProject"
6
+ self.primary_key = "id"
7
+
8
+ belongs_to :integration, foreign_key: :integration_id
9
+ belongs_to :timing_project, foreign_key: :timing_project_id
10
+
11
+ time_column :last_modified_origin
12
+ time_column :last_modified_timing
13
+ time_column :deleted_by_integration_at
14
+ time_column :hidden_at
15
+
16
+ json_column :property_bag
17
+ end
18
+ end
@@ -4,5 +4,13 @@ module Timingapp
4
4
  class Project < TimingRecord
5
5
  self.table_name = "Project"
6
6
  self.primary_key = "id"
7
+
8
+ has_parent
9
+
10
+ belongs_to :membership, foreign_key: :membershipID, class_name: "TODO"
11
+
12
+ scope :archived, -> { where(isArchived: true) }
13
+
14
+ json_column :property_bag
7
15
  end
8
16
  end
@@ -4,5 +4,15 @@ module Timingapp
4
4
  class TaskActivity < TimingRecord
5
5
  self.table_name = "TaskActivity"
6
6
  self.primary_key = "id"
7
+
8
+ belongs_to :project, foreign_key: :projectID
9
+
10
+ scope :running, -> { where(isRunning: true) }
11
+ scope :deleted, -> { where(isDeleted: true) }
12
+
13
+ json_column :property_bag
14
+
15
+ time_column :startDate
16
+ time_column :endDate
7
17
  end
8
18
  end
@@ -11,5 +11,33 @@ module Timingapp
11
11
  def before_destroy
12
12
  raise ActiveRecord::ReadOnlyRecord, "Cannot delete a read-only record"
13
13
  end
14
+
15
+ def self.has_parent(foreign_key = :parentID)
16
+ belongs_to :parent, foreign_key: foreign_key, class_name: name
17
+ end
18
+
19
+ def self.json_column(column)
20
+ define_method(column) do |*args, &block|
21
+ value = super(*args, &block)
22
+
23
+ begin
24
+ JSON.parse(value)
25
+ rescue JSON::ParserError, TypeError
26
+ value
27
+ end
28
+ end
29
+ end
30
+
31
+ def self.time_column(column)
32
+ define_method(column) do |*args, &block|
33
+ value = super(*args, &block)
34
+
35
+ begin
36
+ Time.at(value)
37
+ rescue TypeError
38
+ value
39
+ end
40
+ end
41
+ end
14
42
  end
15
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Timingapp
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/schema.rb CHANGED
@@ -85,88 +85,3 @@ ActiveRecord::Schema[8.0].define(version: 202_301_121_209) do
85
85
  add_foreign_key "Project", "Project", column: "parentID", on_update: :cascade
86
86
  add_foreign_key "TaskActivity", "Project", column: "projectID", on_update: :cascade
87
87
  end
88
- # This file is auto-generated from the current state of the database. Instead
89
- # of editing this file, please use the migrations feature of Active Record to
90
- # incrementally modify your database, and then regenerate this schema definition.
91
- #
92
- # This file is the source Rails uses to define your schema when running `bin/rails
93
- # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
94
- # be faster and is potentially less error prone than running all of your
95
- # migrations from scratch. Old migrations may fail to apply correctly if those
96
- # migrations use external dependencies or application code.
97
- #
98
- # It's strongly recommended that you check this file into your version control system.
99
-
100
- ActiveRecord::Schema[8.0].define(version: 202_301_121_209) do
101
- # Could not dump table "AppActivity" because of following StandardError
102
- # Unknown type 'REAL' for column 'startDate'
103
-
104
- create_table "Application", force: :cascade do |t|
105
- t.text "bundleIdentifier"
106
- t.text "executable"
107
- t.text "title"
108
- t.text "property_bag"
109
- t.index %w[bundleIdentifier executable title], name: "index_application_on_bundleidentifier_executable_title"
110
- end
111
-
112
- create_table "Device", primary_key: "localID", force: :cascade do |t|
113
- t.integer "globalID", null: false
114
- t.binary "macAddress"
115
- t.text "displayName"
116
- t.text "property_bag"
117
- end
118
-
119
- # Could not dump table "Event" because of following StandardError
120
- # Unknown type 'REAL' for column 'start_date'
121
-
122
- # Could not dump table "EventSource" because of following StandardError
123
- # Unknown type 'BOOL' for column 'is_template'
124
-
125
- # Could not dump table "EventSourceTaskActivity" because of following StandardError
126
- # Unknown type 'REAL' for column 'deleted_at'
127
-
128
- create_table "Filter", force: :cascade do |t|
129
- t.integer "parentID"
130
- t.integer "listPosition", null: false
131
- t.text "title", null: false
132
- t.binary "predicate"
133
- t.boolean "isSample", default: false, null: false
134
- t.text "property_bag"
135
- t.index %w[parentID listPosition], name: "index_filter_on_parentid_listposition"
136
- end
137
-
138
- # Could not dump table "Integration" because of following StandardError
139
- # Unknown type 'REAL' for column 'enabled_at'
140
-
141
- # Could not dump table "IntegrationProject" because of following StandardError
142
- # Unknown type 'REAL' for column 'last_modified_origin'
143
-
144
- create_table "Path", force: :cascade do |t|
145
- t.text "stringValue", null: false
146
- end
147
-
148
- # Could not dump table "Project" because of following StandardError
149
- # Unknown type 'REAL' for column 'productivityScore'
150
-
151
- # Could not dump table "TaskActivity" because of following StandardError
152
- # Unknown type 'REAL' for column 'startDate'
153
-
154
- create_table "Title", force: :cascade do |t|
155
- t.text "stringValue", null: false
156
- end
157
-
158
- # Could not dump table "integration_log_result" because of following StandardError
159
- # Unknown type 'REAL' for column 'timestamp'
160
-
161
- add_foreign_key "AppActivity", "Application", column: "applicationID"
162
- add_foreign_key "AppActivity", "Device", column: "localDeviceID", primary_key: "localID"
163
- add_foreign_key "AppActivity", "Path", column: "pathID"
164
- add_foreign_key "AppActivity", "Project", column: "projectID", on_update: :cascade
165
- add_foreign_key "AppActivity", "Title", column: "titleID"
166
- add_foreign_key "Event", "Integration", column: "integration_id"
167
- add_foreign_key "EventSource", "Integration", column: "integration_id"
168
- add_foreign_key "Filter", "Filter", column: "parentID", on_update: :cascade
169
- add_foreign_key "IntegrationProject", "Integration", column: "integration_id"
170
- add_foreign_key "Project", "Project", column: "parentID", on_update: :cascade
171
- add_foreign_key "TaskActivity", "Project", column: "projectID", on_update: :cascade
172
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timingapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
@@ -76,6 +76,7 @@ files:
76
76
  - lib/timingapp/models/filter.rb
77
77
  - lib/timingapp/models/integration.rb
78
78
  - lib/timingapp/models/integration_log_result.rb
79
+ - lib/timingapp/models/integration_project.rb
79
80
  - lib/timingapp/models/path.rb
80
81
  - lib/timingapp/models/project.rb
81
82
  - lib/timingapp/models/schema_migration.rb
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
101
102
  - !ruby/object:Gem::Version
102
- version: 3.1.0
103
+ version: 3.2.0
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
106
  - - ">="