pd1_tools 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +12 -0
- data/exe/pd1 +8 -0
- data/lib/avmtrf1/active_directory/user.rb +28 -0
- data/lib/avmtrf1/active_directory.rb +8 -0
- data/lib/avmtrf1/ad_user.rb +11 -0
- data/lib/avmtrf1/check_point/session/login.rb +57 -0
- data/lib/avmtrf1/check_point/session.rb +60 -0
- data/lib/avmtrf1/check_point.rb +3 -0
- data/lib/avmtrf1/default_esosti.rb +20 -0
- data/lib/avmtrf1/default_jira.rb +18 -0
- data/lib/avmtrf1/default_redmine.rb +16 -0
- data/lib/avmtrf1/docker/image.rb +49 -0
- data/lib/avmtrf1/docker/image_runner.rb +83 -0
- data/lib/avmtrf1/docker.rb +9 -0
- data/lib/avmtrf1/esosti/entities/issue.rb +24 -0
- data/lib/avmtrf1/esosti/entities.rb +9 -0
- data/lib/avmtrf1/esosti/instance/changed.rb +33 -0
- data/lib/avmtrf1/esosti/instance.rb +22 -0
- data/lib/avmtrf1/esosti/raw_data_sanitizer.rb +47 -0
- data/lib/avmtrf1/esosti/session/action_base.rb +34 -0
- data/lib/avmtrf1/esosti/session/atividades.rb +35 -0
- data/lib/avmtrf1/esosti/session/login.rb +47 -0
- data/lib/avmtrf1/esosti/session/solicitacao/main.rb +49 -0
- data/lib/avmtrf1/esosti/session/solicitacao.rb +81 -0
- data/lib/avmtrf1/esosti/session.rb +36 -0
- data/lib/avmtrf1/esosti.rb +8 -0
- data/lib/avmtrf1/executables.rb +23 -0
- data/lib/avmtrf1/forponto/parsers/day_registers.rb +19 -0
- data/lib/avmtrf1/forponto/parsers/espelho/day_node.rb +50 -0
- data/lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb +21 -0
- data/lib/avmtrf1/forponto/parsers/espelho/row_node.rb +34 -0
- data/lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb +71 -0
- data/lib/avmtrf1/forponto/parsers/espelho/sub_node.rb +20 -0
- data/lib/avmtrf1/forponto/parsers/espelho/summary_node.rb +55 -0
- data/lib/avmtrf1/forponto/parsers/espelho/utils.rb +32 -0
- data/lib/avmtrf1/forponto/parsers/espelho.rb +26 -0
- data/lib/avmtrf1/forponto/session/day_registers.rb +39 -0
- data/lib/avmtrf1/forponto/session/interval.rb +27 -0
- data/lib/avmtrf1/forponto/session/login.rb +45 -0
- data/lib/avmtrf1/forponto/session.rb +32 -0
- data/lib/avmtrf1/forponto/user/balance.rb +155 -0
- data/lib/avmtrf1/forponto/user/day_registers.rb +32 -0
- data/lib/avmtrf1/forponto/user/month.rb +141 -0
- data/lib/avmtrf1/forponto/user.rb +22 -0
- data/lib/avmtrf1/git/cached_repository.rb +27 -0
- data/lib/avmtrf1/git/gitlab.rb +11 -0
- data/lib/avmtrf1/git/issue_on_repository.rb +100 -0
- data/lib/avmtrf1/git/push_large/_utils.rb +16 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +21 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/checkout_previous_revision.rb +35 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/commit_changes.rb +48 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/helpers.rb +29 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/pick_source_revision.rb +103 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/push.rb +90 -0
- data/lib/avmtrf1/git/push_large/lfs_commit/track_large_files.rb +53 -0
- data/lib/avmtrf1/git/push_large/lfs_commit.rb +47 -0
- data/lib/avmtrf1/git/push_large/source_commit/push.rb +42 -0
- data/lib/avmtrf1/git/push_large/source_commit.rb +58 -0
- data/lib/avmtrf1/git/push_large.rb +69 -0
- data/lib/avmtrf1/git/reference.rb +34 -0
- data/lib/avmtrf1/git.rb +10 -0
- data/lib/avmtrf1/gitlab/commit.rb +37 -0
- data/lib/avmtrf1/gitlab/repository.rb +41 -0
- data/lib/avmtrf1/ini/profile.rb +42 -0
- data/lib/avmtrf1/ini.rb +55 -0
- data/lib/avmtrf1/inventario_sistemas/parser/body.rb +27 -0
- data/lib/avmtrf1/inventario_sistemas/parser/body_row.rb +12 -0
- data/lib/avmtrf1/inventario_sistemas/parser/header.rb +38 -0
- data/lib/avmtrf1/inventario_sistemas/parser/header_column.rb +27 -0
- data/lib/avmtrf1/inventario_sistemas/parser.rb +40 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/elements.rb +54 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/layout.rb +55 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/stylesheet.css +57 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +41 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/index.rb +20 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/sistema.rb +62 -0
- data/lib/avmtrf1/inventario_sistemas/site_build/sistemas_index.rb +31 -0
- data/lib/avmtrf1/inventario_sistemas/site_build.rb +71 -0
- data/lib/avmtrf1/inventario_sistemas.rb +38 -0
- data/lib/avmtrf1/issues/factory.rb +22 -0
- data/lib/avmtrf1/issues.rb +7 -0
- data/lib/avmtrf1/jira/entities/issue.rb +30 -0
- data/lib/avmtrf1/jira/entities.rb +9 -0
- data/lib/avmtrf1/jira/instance.rb +28 -0
- data/lib/avmtrf1/jira.rb +8 -0
- data/lib/avmtrf1/node_js/docker_image.rb +14 -0
- data/lib/avmtrf1/node_js.rb +9 -0
- data/lib/avmtrf1/openvpn/config/builder.rb +59 -0
- data/lib/avmtrf1/openvpn/config/parser/builder.rb +62 -0
- data/lib/avmtrf1/openvpn/config/parser/line.rb +47 -0
- data/lib/avmtrf1/openvpn/config/parser/simple.rb +27 -0
- data/lib/avmtrf1/openvpn/config/parser/tag.rb +39 -0
- data/lib/avmtrf1/openvpn/config/parser.rb +20 -0
- data/lib/avmtrf1/oracle/connection/base.rb +66 -0
- data/lib/avmtrf1/oracle/connection/string_builder.rb +44 -0
- data/lib/avmtrf1/oracle/connection.rb +12 -0
- data/lib/avmtrf1/oracle/object/base.rb +39 -0
- data/lib/avmtrf1/oracle/object/table.rb +15 -0
- data/lib/avmtrf1/oracle/object/user.rb +15 -0
- data/lib/avmtrf1/oracle/object/view.rb +15 -0
- data/lib/avmtrf1/oracle/object.rb +25 -0
- data/lib/avmtrf1/oracle/objects/relation.rb +23 -0
- data/lib/avmtrf1/oracle/objects/sql_builder.rb +64 -0
- data/lib/avmtrf1/oracle/objects.rb +53 -0
- data/lib/avmtrf1/oracle/oci8.rb +29 -0
- data/lib/avmtrf1/oracle.rb +10 -0
- data/lib/avmtrf1/patches/avm/git/issue/complete.rb +50 -0
- data/lib/avmtrf1/patches/avm/git/issue.rb +4 -0
- data/lib/avmtrf1/patches/avm/git/launcher/base.rb +46 -0
- data/lib/avmtrf1/patches/avm/git/launcher.rb +4 -0
- data/lib/avmtrf1/patches/avm/git.rb +4 -0
- data/lib/avmtrf1/patches/avm.rb +4 -0
- data/lib/avmtrf1/patches/inifile.rb +13 -0
- data/lib/avmtrf1/patches.rb +4 -0
- data/lib/avmtrf1/php/docker_images/base.rb +49 -0
- data/lib/avmtrf1/php/docker_images/factory.rb +37 -0
- data/lib/avmtrf1/php/docker_images/v5.rb +47 -0
- data/lib/avmtrf1/php/docker_images/v7.rb +27 -0
- data/lib/avmtrf1/php/docker_images/v7_v4.rb +30 -0
- data/lib/avmtrf1/php/docker_images/v8.rb +19 -0
- data/lib/avmtrf1/php/docker_images.rb +11 -0
- data/lib/avmtrf1/php.rb +9 -0
- data/lib/avmtrf1/red/client/authorization.xml.erb +4 -0
- data/lib/avmtrf1/red/client.rb +38 -0
- data/lib/avmtrf1/red/helper.rb +35 -0
- data/lib/avmtrf1/red/profile/put_file.xml.erb +19 -0
- data/lib/avmtrf1/red/profile.rb +58 -0
- data/lib/avmtrf1/red/server.rb +33 -0
- data/lib/avmtrf1/red.rb +5 -0
- data/lib/avmtrf1/redmine/entities/issue.rb +29 -0
- data/lib/avmtrf1/redmine/entities/issue_status.rb +23 -0
- data/lib/avmtrf1/redmine/entities.rb +10 -0
- data/lib/avmtrf1/redmine/instance.rb +41 -0
- data/lib/avmtrf1/redmine.rb +7 -0
- data/lib/avmtrf1/rest_provider/entity.rb +18 -0
- data/lib/avmtrf1/rest_provider/instance/issues.rb +30 -0
- data/lib/avmtrf1/rest_provider/instance.rb +30 -0
- data/lib/avmtrf1/rest_provider/request.rb +44 -0
- data/lib/avmtrf1/rest_provider/response.rb +73 -0
- data/lib/avmtrf1/rest_provider.rb +7 -0
- data/lib/avmtrf1/result.rb +44 -0
- data/lib/avmtrf1/ruby.rb +9 -0
- data/lib/avmtrf1/tools/application.rb +13 -0
- data/lib/avmtrf1/tools/core_ext.rb +4 -0
- data/lib/avmtrf1/tools/msgraph/api/entity.rb +35 -0
- data/lib/avmtrf1/tools/msgraph/api/member.rb +31 -0
- data/lib/avmtrf1/tools/msgraph/api/root.rb +27 -0
- data/lib/avmtrf1/tools/msgraph/api/team/member_add.rb +36 -0
- data/lib/avmtrf1/tools/msgraph/api/team.rb +40 -0
- data/lib/avmtrf1/tools/msgraph/api.rb +55 -0
- data/lib/avmtrf1/tools/msgraph/error.rb +31 -0
- data/lib/avmtrf1/tools/msgraph/request_mixin.rb +18 -0
- data/lib/avmtrf1/tools/msgraph/response_mixin.rb +23 -0
- data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
- data/lib/avmtrf1/tools/msgraph.rb +11 -0
- data/lib/avmtrf1/tools/rubygems/dependency.rb +20 -0
- data/lib/avmtrf1/tools/rubygems/not_found_error.rb +17 -0
- data/lib/avmtrf1/tools/rubygems.rb +11 -0
- data/lib/avmtrf1/tools/runner/check_point/login.rb +33 -0
- data/lib/avmtrf1/tools/runner/check_point.rb +17 -0
- data/lib/avmtrf1/tools/runner/esosti/changed.rb +39 -0
- data/lib/avmtrf1/tools/runner/esosti/fetch.rb +39 -0
- data/lib/avmtrf1/tools/runner/esosti/request.rb +76 -0
- data/lib/avmtrf1/tools/runner/esosti.rb +27 -0
- data/lib/avmtrf1/tools/runner/forponto/espelho.rb +47 -0
- data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +32 -0
- data/lib/avmtrf1/tools/runner/forponto/resumos.rb +87 -0
- data/lib/avmtrf1/tools/runner/forponto/saldo.rb +91 -0
- data/lib/avmtrf1/tools/runner/forponto.rb +70 -0
- data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +81 -0
- data/lib/avmtrf1/tools/runner/git/gitlab.rb +20 -0
- data/lib/avmtrf1/tools/runner/git/issues_check.rb +59 -0
- data/lib/avmtrf1/tools/runner/git/push_large.rb +46 -0
- data/lib/avmtrf1/tools/runner/git.rb +14 -0
- data/lib/avmtrf1/tools/runner/inventario_sistemas.rb +71 -0
- data/lib/avmtrf1/tools/runner/msgraph/joined_teams.rb +39 -0
- data/lib/avmtrf1/tools/runner/msgraph/request.rb +45 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/member/add.rb +48 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/member.rb +25 -0
- data/lib/avmtrf1/tools/runner/msgraph/team/members.rb +38 -0
- data/lib/avmtrf1/tools/runner/msgraph/team.rb +27 -0
- data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
- data/lib/avmtrf1/tools/runner/msgraph.rb +43 -0
- data/lib/avmtrf1/tools/runner/node_js/docker.rb +15 -0
- data/lib/avmtrf1/tools/runner/node_js.rb +18 -0
- data/lib/avmtrf1/tools/runner/openvpn.rb +91 -0
- data/lib/avmtrf1/tools/runner/oracle/query.rb +71 -0
- data/lib/avmtrf1/tools/runner/oracle/source_get.rb +51 -0
- data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +59 -0
- data/lib/avmtrf1/tools/runner/oracle.rb +37 -0
- data/lib/avmtrf1/tools/runner/php/docker.rb +20 -0
- data/lib/avmtrf1/tools/runner/php.rb +18 -0
- data/lib/avmtrf1/tools/runner/red.rb +83 -0
- data/lib/avmtrf1/tools/runner/source.rb +14 -0
- data/lib/avmtrf1/tools/runner.rb +43 -0
- data/lib/avmtrf1/tools.rb +4 -0
- data/lib/pd1_tools/version.rb +5 -0
- data/lib/pd1_tools.rb +7 -0
- data/template/avmtrf1/node_js/docker_image/Dockerfile.template +25 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/config_banner.sh +15 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/init.sh +18 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/lib.sh +30 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/ng_serve.sh +16 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/npm_install.sh +21 -0
- data/template/avmtrf1/node_js/docker_image/auxiliary/start.sh +17 -0
- data/template/avmtrf1/php/docker_images/base/Dockerfile.template +104 -0
- data/template/avmtrf1/php/docker_images/base/aux/apache_foreground.sh +16 -0
- data/template/avmtrf1/php/docker_images/base/aux/apache_user.sh +54 -0
- data/template/avmtrf1/php/docker_images/base/aux/app_user_run.sh +17 -0
- data/template/avmtrf1/php/docker_images/base/aux/config_banner.sh +20 -0
- data/template/avmtrf1/php/docker_images/base/aux/init.sh +39 -0
- data/template/avmtrf1/php/docker_images/base/aux/laravel.sh +58 -0
- data/template/avmtrf1/php/docker_images/base/aux/lib.sh +70 -0
- data/template/avmtrf1/php/docker_images/base/aux/pear.sh +35 -0
- data/template/avmtrf1/php/docker_images/base/aux/php_composer.sh +31 -0
- data/template/avmtrf1/php/docker_images/base/aux/php_values.sh +41 -0
- data/template/avmtrf1/php/docker_images/base/aux/setup_apache_site.sh +16 -0
- data/template/avmtrf1/php/docker_images/base/aux/start.sh +26 -0
- data/template/avmtrf1/php/docker_images/base/aux/templates/apache_site.conf +12 -0
- data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
- metadata +460 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Forponto
|
5
|
+
class User
|
6
|
+
class Balance
|
7
|
+
include ::EacRubyUtils::SimpleCache
|
8
|
+
|
9
|
+
attr_reader :user
|
10
|
+
|
11
|
+
def initialize(user)
|
12
|
+
@user = user
|
13
|
+
build_balances
|
14
|
+
end
|
15
|
+
|
16
|
+
def months_balances_uncached
|
17
|
+
sorted_months.map { |m| MyBalance.new(m) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def sorted_months_uncached
|
21
|
+
r = []
|
22
|
+
current = head_month
|
23
|
+
while current.present?
|
24
|
+
r << current
|
25
|
+
current = current.parent_month
|
26
|
+
end
|
27
|
+
r.reverse
|
28
|
+
end
|
29
|
+
|
30
|
+
def head_month
|
31
|
+
today = ::Date.today # rubocop:disable Rails/Date
|
32
|
+
date = ::Date.civil(today.year, today.month, 1)
|
33
|
+
user.month(date.year, date.month)
|
34
|
+
end
|
35
|
+
|
36
|
+
def debito_left
|
37
|
+
months_balances.inject(0) { |a, e| a + e.debito.left }
|
38
|
+
end
|
39
|
+
|
40
|
+
def credito_left
|
41
|
+
months_balances.inject(0) { |a, e| a + e.credito.left }
|
42
|
+
end
|
43
|
+
|
44
|
+
def saldo_left
|
45
|
+
credito_left - debito_left
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def build_balances
|
51
|
+
previous = []
|
52
|
+
months_balances.each do |current|
|
53
|
+
current.consume(previous)
|
54
|
+
previous << current
|
55
|
+
if previous.count > 3
|
56
|
+
removed = previous.shift
|
57
|
+
removed.mark_lost
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class MyBalance
|
63
|
+
attr_accessor :debito, :credito, :month, :lost
|
64
|
+
|
65
|
+
def initialize(month)
|
66
|
+
@month = month
|
67
|
+
@debito = AttrConsumer.new(self, false, month.debito)
|
68
|
+
@credito = AttrConsumer.new(self, true, month.credito)
|
69
|
+
@lost = false
|
70
|
+
end
|
71
|
+
|
72
|
+
def after_trigger
|
73
|
+
credito.after_trigger - debito.after_trigger
|
74
|
+
end
|
75
|
+
|
76
|
+
def after_trigger_acum
|
77
|
+
credito.after_trigger_acum - debito.after_trigger_acum
|
78
|
+
end
|
79
|
+
|
80
|
+
def mark_lost
|
81
|
+
@lost = true
|
82
|
+
end
|
83
|
+
|
84
|
+
delegate :to_s, to: :month
|
85
|
+
|
86
|
+
def consume(previous)
|
87
|
+
debito.consume_from_months(previous)
|
88
|
+
credito.consume_from_months(previous)
|
89
|
+
end
|
90
|
+
|
91
|
+
class AttrConsumer
|
92
|
+
attr_reader :owner_month, :initial_value, :left, :unconsumed, :withdrawals, :requests,
|
93
|
+
:after_trigger, :after_trigger_acum
|
94
|
+
|
95
|
+
def initialize(owner_month, credito, initial_value)
|
96
|
+
@owner_month = owner_month
|
97
|
+
@credito = credito
|
98
|
+
@left = initial_value
|
99
|
+
@initial_value = initial_value
|
100
|
+
@withdrawals = []
|
101
|
+
@requests = []
|
102
|
+
@after_trigger = nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_s
|
106
|
+
"[#{owner_month}|#{attr}]"
|
107
|
+
end
|
108
|
+
|
109
|
+
def consume_from_months(months)
|
110
|
+
(months + [owner_month]).each do |month|
|
111
|
+
break unless left.positive?
|
112
|
+
|
113
|
+
consume_from_month(month)
|
114
|
+
end
|
115
|
+
@after_trigger = left
|
116
|
+
@after_trigger_acum = months.inject(0) { |a, e| a + e.send(attr).left } + left
|
117
|
+
end
|
118
|
+
|
119
|
+
def withdrawal(month, value)
|
120
|
+
month.assert_argument(MyBalance, :month)
|
121
|
+
raise "Value is not positive: #{value} (Month: #{month})" unless value.positive?
|
122
|
+
|
123
|
+
self.left -= value
|
124
|
+
raise "Left less than zero: #{left} (Value: #{value})" if left.negative?
|
125
|
+
|
126
|
+
@withdrawals << OpenStruct.new(month: month, value: value) # rubocop:disable Style/OpenStructUse
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
attr_writer :left, :unconsumed
|
132
|
+
|
133
|
+
def consume_from_month(month)
|
134
|
+
month_attr = month.send(reverse_attr)
|
135
|
+
return unless month_attr.left.positive?
|
136
|
+
|
137
|
+
value = [left, month_attr.left].min
|
138
|
+
self.left -= value
|
139
|
+
month_attr.withdrawal(owner_month, value)
|
140
|
+
@requests << OpenStruct.new(month: month, value: value) # rubocop:disable Style/OpenStructUse
|
141
|
+
end
|
142
|
+
|
143
|
+
def attr
|
144
|
+
@credito ? :credito : :debito
|
145
|
+
end
|
146
|
+
|
147
|
+
def reverse_attr
|
148
|
+
@credito ? :debito : :credito
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Forponto
|
7
|
+
class User
|
8
|
+
class DayRegisters
|
9
|
+
enable_simple_cache
|
10
|
+
common_constructor :user
|
11
|
+
|
12
|
+
def date
|
13
|
+
fresh_data
|
14
|
+
@date
|
15
|
+
end
|
16
|
+
|
17
|
+
def times
|
18
|
+
fresh_data.map { |r| r[:hora] }
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def fresh_data_uncached
|
24
|
+
r = ::Avmtrf1::Forponto::Session.new(user.url, user.matricula, user.codigo)
|
25
|
+
.day_registers_data
|
26
|
+
@date = ::Date.today # rubocop:disable Rails/Date
|
27
|
+
r
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/json'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/yaml'
|
6
|
+
require 'recursive-open-struct'
|
7
|
+
require 'avmtrf1/forponto/parsers/espelho'
|
8
|
+
require 'avmtrf1/forponto/session'
|
9
|
+
|
10
|
+
module Avmtrf1
|
11
|
+
module Forponto
|
12
|
+
class User
|
13
|
+
class Month
|
14
|
+
enable_simple_cache
|
15
|
+
|
16
|
+
DEBITO_CODE = 66
|
17
|
+
CREDITO_CODE = 72
|
18
|
+
|
19
|
+
attr_reader :user, :year, :month
|
20
|
+
|
21
|
+
def initialize(user, year, month)
|
22
|
+
@user = user
|
23
|
+
@year = year
|
24
|
+
@month = month
|
25
|
+
end
|
26
|
+
|
27
|
+
def data_uncached
|
28
|
+
if recache?
|
29
|
+
r = fresh_data
|
30
|
+
data_cache.write(r.to_yaml)
|
31
|
+
r
|
32
|
+
else
|
33
|
+
cached_data
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
month.to_s.rjust(2, '0') + '/' + year.to_s # rubocop:disable Style/StringConcatenation
|
39
|
+
end
|
40
|
+
|
41
|
+
def empty?
|
42
|
+
os_data.summaries.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def debito_acumulado; end
|
46
|
+
|
47
|
+
def debito
|
48
|
+
summary_minutes(DEBITO_CODE)
|
49
|
+
end
|
50
|
+
|
51
|
+
def debito_acum
|
52
|
+
debito + (parent_month ? parent_month.debito_acum : 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
def credito_acum
|
56
|
+
credito + (parent_month ? parent_month.credito_acum : 0)
|
57
|
+
end
|
58
|
+
|
59
|
+
def saldo
|
60
|
+
credito - debito
|
61
|
+
end
|
62
|
+
|
63
|
+
def saldo_acum
|
64
|
+
credito_acum - debito_acum
|
65
|
+
end
|
66
|
+
|
67
|
+
def credito
|
68
|
+
summary_minutes(CREDITO_CODE)
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def summary_minutes(code)
|
74
|
+
summary = os_data.summaries.find { |s| s.code == code }
|
75
|
+
summary ? summary.minutes : 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def parent_month_uncached
|
79
|
+
date = Date.civil(year, month, 1) - 1.month
|
80
|
+
r = user.month(date.year, date.month)
|
81
|
+
r.empty? ? nil : r
|
82
|
+
end
|
83
|
+
|
84
|
+
def os_data_uncached
|
85
|
+
::RecursiveOpenStruct.new(data, recurse_over_arrays: true)
|
86
|
+
end
|
87
|
+
|
88
|
+
def recache?
|
89
|
+
!data_cache.stored? || yesterday_uncached?
|
90
|
+
end
|
91
|
+
|
92
|
+
def yesterday_uncached?
|
93
|
+
last_cached_day < end_date && last_cached_day < (::Date.today - 1.day) # rubocop:disable Rails/Date
|
94
|
+
end
|
95
|
+
|
96
|
+
def last_cached_day_uncached
|
97
|
+
cached_data.fetch('days').map { |day| day.fetch('date') }.max
|
98
|
+
end
|
99
|
+
|
100
|
+
def data_cache_uncached
|
101
|
+
::Avmtrf1.fs_cache.child('forponto', user.matricula, year.to_s, month.to_s.rjust(2, '0'))
|
102
|
+
end
|
103
|
+
|
104
|
+
def date(day)
|
105
|
+
::Date.civil(year, month, day)
|
106
|
+
end
|
107
|
+
|
108
|
+
def start_date_uncached
|
109
|
+
date(1)
|
110
|
+
end
|
111
|
+
|
112
|
+
def end_date_uncached
|
113
|
+
date(-1)
|
114
|
+
end
|
115
|
+
|
116
|
+
def cached_data
|
117
|
+
raise 'There is no data cached' unless data_cache.stored?
|
118
|
+
|
119
|
+
::EacRubyUtils::Yaml.load(data_cache.read)
|
120
|
+
end
|
121
|
+
|
122
|
+
def fresh_data
|
123
|
+
session = new_session
|
124
|
+
begin
|
125
|
+
session.interval_data(start_date, end_date).merge(fetch_data)
|
126
|
+
ensure
|
127
|
+
session.sub.close
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def fetch_data
|
132
|
+
{ year: year, month: month, url: user.url, matricula: user.matricula }
|
133
|
+
end
|
134
|
+
|
135
|
+
def new_session
|
136
|
+
::Avmtrf1::Forponto::Session.new(user.url, user.matricula, user.codigo)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
EacRubyUtils.require_sub(__FILE__)
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
class User
|
9
|
+
attr_reader :url, :matricula, :codigo
|
10
|
+
|
11
|
+
def initialize(url, matricula, codigo)
|
12
|
+
@url = url
|
13
|
+
@matricula = matricula
|
14
|
+
@codigo = codigo
|
15
|
+
end
|
16
|
+
|
17
|
+
def month(year, month)
|
18
|
+
::Avmtrf1::Forponto::User::Month.new(self, year, month)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/launcher/base'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Git
|
7
|
+
class CachedRepository < ::Avm::Git::Launcher::Base
|
8
|
+
attr_reader :url
|
9
|
+
|
10
|
+
def initialize(url)
|
11
|
+
@url = url
|
12
|
+
super(local_path)
|
13
|
+
init
|
14
|
+
assert_remote_url('origin', url)
|
15
|
+
system!('fetch', 'origin', '-pPt')
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def local_path
|
21
|
+
r = ::File.join(ENV.fetch('HOME', nil), '.cache', 'git_cached_repositories', url.parameterize) # rubocop:disable Style/EnvHome, Layout/LineLength
|
22
|
+
::FileUtils.mkdir_p(::File.dirname(r))
|
23
|
+
r
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/speaker'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'avmtrf1/result'
|
6
|
+
|
7
|
+
module Avmtrf1
|
8
|
+
module Git
|
9
|
+
class IssueOnRepository
|
10
|
+
enable_speaker
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
|
13
|
+
CHECKS = %w[no_branch_nor_tag branch_and_tag issue_not_found issue_closed_git_open
|
14
|
+
issue_open_git_closed issue_open_git_open issue_closed_git_closed].freeze
|
15
|
+
|
16
|
+
def initialize(issue_id, refs)
|
17
|
+
@issue_id = issue_id
|
18
|
+
@refs = refs
|
19
|
+
end
|
20
|
+
|
21
|
+
def check
|
22
|
+
infov issue_id, "#{result.label} [#{issue ? issue.status_name : '-'}]"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :issue_id, :refs
|
28
|
+
|
29
|
+
def result_uncached
|
30
|
+
CHECKS.each do |check|
|
31
|
+
result = send("#{check}_check")
|
32
|
+
return result if result
|
33
|
+
end
|
34
|
+
::Avmtrf1::Result.error('condição não encontrada')
|
35
|
+
end
|
36
|
+
|
37
|
+
def no_branch_nor_tag_check
|
38
|
+
return nil unless branch_ref.blank? && tag_ref.blank?
|
39
|
+
|
40
|
+
::Avmtrf1::Result.error("nem branch nem tag encontrado com o nome \"#{issue_id}\"")
|
41
|
+
end
|
42
|
+
|
43
|
+
def branch_and_tag_check
|
44
|
+
return nil unless branch_ref.present? && tag_ref.present?
|
45
|
+
|
46
|
+
::Avmtrf1::Result.error("há uma branch e uma tag com o nome \"#{issue_id}\"")
|
47
|
+
end
|
48
|
+
|
49
|
+
def issue_not_found_check
|
50
|
+
return nil if issue.present?
|
51
|
+
|
52
|
+
if tag_ref.present?
|
53
|
+
::Avmtrf1::Result.neutral('demanda não encontrada e Git fechado')
|
54
|
+
else
|
55
|
+
::Avmtrf1::Result.neutral('demanda não encontrada e Git aberto')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def issue_closed_git_open_check
|
60
|
+
return nil unless issue.closed? && !git_closed?
|
61
|
+
|
62
|
+
::Avmtrf1::Result.error('demanda fechada e Git aberto')
|
63
|
+
end
|
64
|
+
|
65
|
+
def issue_open_git_closed_check
|
66
|
+
return nil unless !issue.closed? && git_closed?
|
67
|
+
|
68
|
+
::Avmtrf1::Result.error('demanda aberta e Git fechado')
|
69
|
+
end
|
70
|
+
|
71
|
+
def issue_open_git_open_check
|
72
|
+
return nil unless !issue.closed? && !git_closed?
|
73
|
+
|
74
|
+
::Avmtrf1::Result.success('demanda aberta e Git aberto')
|
75
|
+
end
|
76
|
+
|
77
|
+
def issue_closed_git_closed_check
|
78
|
+
return nil unless issue.closed? && git_closed?
|
79
|
+
|
80
|
+
::Avmtrf1::Result.success('demanda fechada e Git fechado')
|
81
|
+
end
|
82
|
+
|
83
|
+
def git_closed?
|
84
|
+
tag_ref.present?
|
85
|
+
end
|
86
|
+
|
87
|
+
def branch_ref_uncached
|
88
|
+
refs.find { |ref| ref.type == 'head' }
|
89
|
+
end
|
90
|
+
|
91
|
+
def tag_ref_uncached
|
92
|
+
refs.find { |ref| ref.type == 'tag' }
|
93
|
+
end
|
94
|
+
|
95
|
+
def issue_uncached
|
96
|
+
::Avmtrf1::IssueFactory.find(issue_id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Git
|
5
|
+
class PushLarge
|
6
|
+
class LfsCommit
|
7
|
+
module Cache
|
8
|
+
def fs_cache
|
9
|
+
@fs_cache ||= source_commit.fs_cache.child(
|
10
|
+
lfs_file_min_size.presence || 'nil'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
%w[sha1 files_size push_pack_error].each do |attr|
|
15
|
+
define_method("#{attr}_cache_uncached") { fs_cache.child(attr) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Git
|
5
|
+
class PushLarge
|
6
|
+
class LfsCommit
|
7
|
+
module CheckoutPreviousRevision
|
8
|
+
private
|
9
|
+
|
10
|
+
def checkout_base_uncached
|
11
|
+
if previous_revision.blank?
|
12
|
+
checkout_orphan
|
13
|
+
else
|
14
|
+
checkout_previous_revision
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def checkout_orphan
|
19
|
+
infom message('Checkout orphan')
|
20
|
+
git.execute!('reset', '--hard')
|
21
|
+
git.execute!('clean', '-df')
|
22
|
+
git.execute!('checkout', source_commit.sha1)
|
23
|
+
end
|
24
|
+
|
25
|
+
def checkout_previous_revision
|
26
|
+
infom message("Checkout previous revision #{previous_revision}")
|
27
|
+
git.execute!('reset', '--hard')
|
28
|
+
git.execute!('clean', '-df')
|
29
|
+
git.execute!('checkout', previous_revision)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Git
|
5
|
+
class PushLarge
|
6
|
+
class LfsCommit
|
7
|
+
module CommitChanges
|
8
|
+
# @return [Avm::Git::Commit]
|
9
|
+
def commit
|
10
|
+
commit_changes
|
11
|
+
@commit
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def commit_changes_uncached
|
17
|
+
if sha1_cache.read.present?
|
18
|
+
@commit = ::Avm::Git::Commit.new(git, sha1_cache.read)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
track_large_files
|
22
|
+
add_files
|
23
|
+
commit_amend
|
24
|
+
store_commit
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_files
|
28
|
+
infom ' * Adding files'
|
29
|
+
git.system!('add', '.')
|
30
|
+
end
|
31
|
+
|
32
|
+
def commit_amend
|
33
|
+
infom message('Commiting')
|
34
|
+
git.command('commit', '--amend', '--allow-empty', '--allow-empty-message')
|
35
|
+
.envvar('GIT_EDITOR', true).execute!
|
36
|
+
end
|
37
|
+
|
38
|
+
def store_commit
|
39
|
+
@commit = ::Avm::Git::Commit.new(git, git.rev_parse('HEAD'))
|
40
|
+
infov message('Commited (SHA1)'), @commit.sha1
|
41
|
+
sha1_cache.write(@commit.sha1)
|
42
|
+
files_size_cache.write(@commit.files_size)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Git
|
5
|
+
class PushLarge
|
6
|
+
class LfsCommit
|
7
|
+
module Helpers
|
8
|
+
private
|
9
|
+
|
10
|
+
def message(suffix, padding = 0)
|
11
|
+
"#{' ' * (padding + 2)}* #{suffix}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def git
|
15
|
+
source_commit.git
|
16
|
+
end
|
17
|
+
|
18
|
+
def push_large
|
19
|
+
source_commit.push_large
|
20
|
+
end
|
21
|
+
|
22
|
+
def previous_revision
|
23
|
+
push_large.last_pushed_revision
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|