twenty-server 0.4.3 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/twenty/server/graphql/type/project.rb +1 -0
- data/lib/twenty/server/graphql/type/query.rb +4 -1
- data/lib/twenty/server/model/project.rb +26 -1
- data/lib/twenty/server/rack/graphql.rb +3 -3
- data/lib/twenty/server.rb +37 -0
- data/share/twenty/server/schema.graphql +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b83eb9e96d4001197f2e9b1433fafcb65b596be12ee1ee524e65a052f1414ee6
|
4
|
+
data.tar.gz: 888fa18f5343736fc57aaf55b9be0cc35939420296a7bc42b24bc5d7a06bf2a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba09669cff1d0342c78a4b1f972a6d61028b31103fddfa1330f3d859dd533e51a46198c5636f4a28ceb4202889d891d251fa432c6c626b1a21a569c6a723ce57
|
7
|
+
data.tar.gz: 0a05f5c006ce39024ab619133bb26de572c3aa97faf7430979336c0c8a051557d2d88120fbc3c79a95840ff4a6b9447bb56118d739d62b671af45b2cdb7724df
|
@@ -8,10 +8,35 @@ class Twenty::Project < Sequel::Model
|
|
8
8
|
validates_presence_of :path
|
9
9
|
one_to_many :tasks, class_name: "Twenty::Task"
|
10
10
|
|
11
|
+
##
|
12
|
+
# @api private
|
13
|
+
def validate
|
14
|
+
super
|
15
|
+
errors.add(:path, "does not exist on disk") if !path_exist?
|
16
|
+
errors.add(:path, "is not absolute") if !File.absolute_path?(path)
|
17
|
+
end
|
18
|
+
|
11
19
|
##
|
12
20
|
# @return [String]
|
13
|
-
# The path to a project
|
21
|
+
# The path to a project
|
14
22
|
def path
|
15
23
|
super&.sub(Dir.home, "~")
|
16
24
|
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# @return [Boolean]
|
28
|
+
# Returns true when {#path} exists on disk
|
29
|
+
def path_exist?
|
30
|
+
File.exist? File.expand_path(path)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# @return [Integer]
|
35
|
+
# Returns the number of open tasks a project has
|
36
|
+
def open_task_count
|
37
|
+
@open_task_count ||= Twenty::Task
|
38
|
+
.where(project_id: id)
|
39
|
+
.where(Sequel.lit("status IN (0,1,2)"))
|
40
|
+
.count
|
41
|
+
end
|
17
42
|
end
|
@@ -4,13 +4,13 @@ module Twenty::Rack
|
|
4
4
|
module GraphQL
|
5
5
|
##
|
6
6
|
# Extends {Server::Dir Server::Dir} (a static file
|
7
|
-
# Rack application) with a /graphql endpoint
|
7
|
+
# Rack application) with a /graphql endpoint
|
8
8
|
#
|
9
9
|
# @param [Hash] env
|
10
|
-
# Environment hash
|
10
|
+
# Environment hash
|
11
11
|
#
|
12
12
|
# @return [Array<Integer, Hash, #each>]
|
13
|
-
# Returns a response
|
13
|
+
# Returns a response
|
14
14
|
def call(env)
|
15
15
|
req = Rack::Request.new(env)
|
16
16
|
if req.post? &&
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twenty
|
4
|
+
require "fileutils"
|
5
|
+
require "sequel"
|
6
|
+
require_relative "server/path"
|
7
|
+
|
8
|
+
##
|
9
|
+
# @return [String]
|
10
|
+
# Returns the location of the default SQLite database.
|
11
|
+
def self.default_database
|
12
|
+
@default_database ||= File.join(Path.datadir, "database.sqlite")
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Establishes a database connection.
|
17
|
+
#
|
18
|
+
# @param [String] path
|
19
|
+
# The path to a SQLite3 database file.
|
20
|
+
#
|
21
|
+
# @return [void]
|
22
|
+
def self.establish_connection(path:)
|
23
|
+
@connection = Sequel.connect(
|
24
|
+
adapter: "sqlite",
|
25
|
+
database: path
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.connection
|
30
|
+
establish_connection unless @connection
|
31
|
+
@connection
|
32
|
+
end
|
33
|
+
|
34
|
+
FileUtils.touch(default_database)
|
35
|
+
require_relative "server/graphql"
|
36
|
+
require_relative "server/rack"
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -101,6 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- "./lib/twenty/server.rb"
|
104
105
|
- "./lib/twenty/server/graphql.rb"
|
105
106
|
- "./lib/twenty/server/graphql/input.rb"
|
106
107
|
- "./lib/twenty/server/graphql/input/task_input.rb"
|