discourse_plugin_statistics 0.1.0.pre3 → 0.1.0.pre5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3a9895060005a6e8c1b96f19769ac296a044c8b2fee341a812f2ce8b7835c9f
4
- data.tar.gz: eff6c181bb2a24f62602e3adddc24849121173a0020b8a59a305fa65beab8e73
3
+ metadata.gz: f0ae8228274c7608227e6f43cde59bfcc1ba9439e84700327046b2be31358912
4
+ data.tar.gz: f2647b45ff91752b9cfb34e7835f50e01241cbc582e5ab2a856590d1b7d0f0af
5
5
  SHA512:
6
- metadata.gz: 4bb597a6df5115c7c4da006bebb2df26df9ac26b2a9ddd35266c9862737672b474c9e21475f1fc54f75f58840a145fa2b161dc7a724524d8be095c6f8231780b
7
- data.tar.gz: 547c05922a453ebaa6d5ced40ce8cabf256ca0210d1a71f84a44214de34ce9bcff1001000abcbe83904457ecbea7a4084db0750f45383bec5dc64d63f1a00759
6
+ metadata.gz: 03b52b0cdeade6fdd80fd71b3b736ed345cde720817b231440b5600c44491b0e6f56b9c98331341a702fb9d95bb1eb1b9357aadc27abbc9df41ca052e9f4812f
7
+ data.tar.gz: 833048742be89bbc38c210b2633615584158fcef8038a23f63d739249efacb68c899a333a3e3110a3b32152ffade04277cd68763ef65588911c87664fbfdfdff
@@ -4,24 +4,39 @@ require "excon"
4
4
 
5
5
  module DiscoursePluginStatistics
6
6
  class Statistics
7
+ PATH = "plugin-manager/statistics"
8
+
7
9
  def self.update!
8
10
  new.update
9
11
  end
10
12
 
11
13
  def update
14
+ body = {
15
+ discourse: discourse,
16
+ plugins: plugins
17
+ }.to_json
18
+
19
+ response = request(body)
20
+
21
+ if response && [301, 302, 303].include?(response[:status])
22
+ location = response[:headers]["Location"]
23
+ response = request(body, location) if location
24
+ end
25
+
26
+ response
27
+ end
28
+
29
+ protected
30
+
31
+ def request(body, url = nil)
12
32
  ::Excon.post(
13
- DiscoursePluginStatistics.server_url,
33
+ url || "#{DiscoursePluginStatistics.server_url}/#{PATH}",
14
34
  headers: { "Content-Type" => "application/json" },
15
- body: {
16
- discourse: discourse,
17
- plugins: plugins
18
- }.to_json
35
+ body: body
19
36
  )
20
37
  rescue Excon::Error
21
38
  end
22
39
 
23
- protected
24
-
25
40
  def discourse
26
41
  @discourse ||= DiscoursePluginStatistics::Discourse.new.json
27
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiscoursePluginStatistics
4
- VERSION = "0.1.0.pre3"
4
+ VERSION = "0.1.0.pre5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_plugin_statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0.pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angus McLeod
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-04 00:00:00.000000000 Z
11
+ date: 2023-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers