aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:24:32 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:24:34 -0800
commit34839845429e066b5c44a19fba95711b14c196e2 (patch)
tree9a703a934db85a8ac0694ea10900ec702a2e82e0
parent8b2590b32e7b6bd2bfa518ec59c492dd48f8047f (diff)
downloadfatcat-34839845429e066b5c44a19fba95711b14c196e2.tar.gz
fatcat-34839845429e066b5c44a19fba95711b14c196e2.zip
remove unused postgres-backed stats stuff
Will replace with elasticsearch-based dash in webface
-rw-r--r--fatcat-openapi2.yml23
-rw-r--r--python/fatcat_client/README.md2
-rw-r--r--python/fatcat_client/__init__.py1
-rw-r--r--python/fatcat_client/api/default_api.py93
-rw-r--r--python/fatcat_client/models/__init__.py1
-rw-r--r--python/fatcat_web/routes.py8
-rw-r--r--python/fatcat_web/templates/stats.html104
-rw-r--r--python/tests/codegen_tests/test_default_api.py6
-rw-r--r--python/tests/codegen_tests/test_stats_response.py40
-rw-r--r--python/tests/routes.py3
-rw-r--r--rust/fatcat-api-spec/README.md3
-rw-r--r--rust/fatcat-api-spec/api.yaml23
-rw-r--r--rust/fatcat-api-spec/api/swagger.yaml42
-rw-r--r--rust/fatcat-api-spec/examples/client.rs8
-rw-r--r--rust/fatcat-api-spec/examples/server_lib/server.rs8
-rw-r--r--rust/fatcat-api-spec/src/client.rs51
-rw-r--r--rust/fatcat-api-spec/src/lib.rs16
-rw-r--r--rust/fatcat-api-spec/src/mimetypes.rs8
-rw-r--r--rust/fatcat-api-spec/src/models.rs13
-rw-r--r--rust/fatcat-api-spec/src/server.rs60
-rw-r--r--rust/src/api_server.rs84
-rw-r--r--rust/src/api_wrappers.rs19
-rw-r--r--rust/tests/test_api_server_http.rs20
23 files changed, 10 insertions, 626 deletions
diff --git a/fatcat-openapi2.yml b/fatcat-openapi2.yml
index b514da49..018b58e9 100644
--- a/fatcat-openapi2.yml
+++ b/fatcat-openapi2.yml
@@ -416,12 +416,6 @@ definitions:
additionalProperties: {}
role:
type: string
- stats_response:
- type: object
- properties:
- extra:
- type: object
- additionalProperties: {}
x-entity-responses: &ENTITYRESPONSES
400:
@@ -1910,20 +1904,3 @@ paths:
description: Generic Error
schema:
$ref: "#/definitions/error_response"
- /stats:
- get:
- operationId: "get_stats"
- parameters:
- - name: more
- in: query
- type: string
- required: false
- responses:
- 200:
- description: Success
- schema:
- $ref: "#/definitions/stats_response"
- 500:
- description: Generic Error
- schema:
- $ref: "#/definitions/error_response"
diff --git a/python/fatcat_client/README.md b/python/fatcat_client/README.md
index cf9a73cc..88db0ca4 100644
--- a/python/fatcat_client/README.md
+++ b/python/fatcat_client/README.md
@@ -117,7 +117,6 @@ Class | Method | HTTP request | Description
*DefaultApi* | [**get_release_history**](docs/DefaultApi.md#get_release_history) | **GET** /release/{ident}/history |
*DefaultApi* | [**get_release_redirects**](docs/DefaultApi.md#get_release_redirects) | **GET** /release/{ident}/redirects |
*DefaultApi* | [**get_release_revision**](docs/DefaultApi.md#get_release_revision) | **GET** /release/rev/{rev_id} |
-*DefaultApi* | [**get_stats**](docs/DefaultApi.md#get_stats) | **GET** /stats |
*DefaultApi* | [**get_work**](docs/DefaultApi.md#get_work) | **GET** /work/{ident} |
*DefaultApi* | [**get_work_edit**](docs/DefaultApi.md#get_work_edit) | **GET** /work/edit/{edit_id} |
*DefaultApi* | [**get_work_history**](docs/DefaultApi.md#get_work_history) | **GET** /work/{ident}/history |
@@ -152,7 +151,6 @@ Class | Method | HTTP request | Description
- [ReleaseEntity](docs/ReleaseEntity.md)
- [ReleaseEntityAbstracts](docs/ReleaseEntityAbstracts.md)
- [ReleaseRef](docs/ReleaseRef.md)
- - [StatsResponse](docs/StatsResponse.md)
- [Success](docs/Success.md)
- [WorkEntity](docs/WorkEntity.md)
diff --git a/python/fatcat_client/__init__.py b/python/fatcat_client/__init__.py
index 863892e6..f126b749 100644
--- a/python/fatcat_client/__init__.py
+++ b/python/fatcat_client/__init__.py
@@ -37,6 +37,5 @@ from fatcat_client.models.release_contrib import ReleaseContrib
from fatcat_client.models.release_entity import ReleaseEntity
from fatcat_client.models.release_entity_abstracts import ReleaseEntityAbstracts
from fatcat_client.models.release_ref import ReleaseRef
-from fatcat_client.models.stats_response import StatsResponse
from fatcat_client.models.success import Success
from fatcat_client.models.work_entity import WorkEntity
diff --git a/python/fatcat_client/api/default_api.py b/python/fatcat_client/api/default_api.py
index e2194ce9..3f83b418 100644
--- a/python/fatcat_client/api/default_api.py
+++ b/python/fatcat_client/api/default_api.py
@@ -4966,99 +4966,6 @@ class DefaultApi(object):
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
- def get_stats(self, **kwargs): # noqa: E501
- """get_stats # noqa: E501
-
- This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async=True
- >>> thread = api.get_stats(async=True)
- >>> result = thread.get()
-
- :param async bool
- :param str more:
- :return: StatsResponse
- If the method is called asynchronously,
- returns the request thread.
- """
- kwargs['_return_http_data_only'] = True
- if kwargs.get('async'):
- return self.get_stats_with_http_info(**kwargs) # noqa: E501
- else:
- (data) = self.get_stats_with_http_info(**kwargs) # noqa: E501
- return data
-
- def get_stats_with_http_info(self, **kwargs): # noqa: E501
- """get_stats # noqa: E501
-
- This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async=True
- >>> thread = api.get_stats_with_http_info(async=True)
- >>> result = thread.get()
-
- :param async bool
- :param str more:
- :return: StatsResponse
- If the method is called asynchronously,
- returns the request thread.
- """
-
- all_params = ['more'] # noqa: E501
- all_params.append('async')
- all_params.append('_return_http_data_only')
- all_params.append('_preload_content')
- all_params.append('_request_timeout')
-
- params = locals()
- for key, val in six.iteritems(params['kwargs']):
- if key not in all_params:
- raise TypeError(
- "Got an unexpected keyword argument '%s'"
- " to method get_stats" % key
- )
- params[key] = val
- del params['kwargs']
-
- collection_formats = {}
-
- path_params = {}
-
- query_params = []
- if 'more' in params:
- query_params.append(('more', params['more'])) # noqa: E501
-
- header_params = {}
-
- form_params = []
- local_var_files = {}
-
- body_params = None
- # HTTP header `Accept`
- header_params['Accept'] = self.api_client.select_header_accept(
- ['application/json']) # noqa: E501
-
- # HTTP header `Content-Type`
- header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
- ['application/json']) # noqa: E501
-
- # Authentication setting
- auth_settings = [] # noqa: E501
-
- return self.api_client.call_api(
- '/stats', 'GET',
- path_params,
- query_params,
- header_params,
- body=body_params,
- post_params=form_params,
- files=local_var_files,
- response_type='StatsResponse', # noqa: E501
- auth_settings=auth_settings,
- async=params.get('async'),
- _return_http_data_only=params.get('_return_http_data_only'),
- _preload_content=params.get('_preload_content', True),
- _request_timeout=params.get('_request_timeout'),
- collection_formats=collection_formats)
-
def get_work(self, ident, **kwargs): # noqa: E501
"""get_work # noqa: E501
diff --git a/python/fatcat_client/models/__init__.py b/python/fatcat_client/models/__init__.py
index fb0f9ab1..db9d2e5d 100644
--- a/python/fatcat_client/models/__init__.py
+++ b/python/fatcat_client/models/__init__.py
@@ -30,6 +30,5 @@ from fatcat_client.models.release_contrib import ReleaseContrib
from fatcat_client.models.release_entity import ReleaseEntity
from fatcat_client.models.release_entity_abstracts import ReleaseEntityAbstracts
from fatcat_client.models.release_ref import ReleaseRef
-from fatcat_client.models.stats_response import StatsResponse
from fatcat_client.models.success import Success
from fatcat_client.models.work_entity import WorkEntity
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 0a1ea2c6..998697bc 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -343,14 +343,6 @@ def changelog_entry_view(index):
abort(ae.status)
return render_template('changelog_view.html', entry=entry, editgroup=entry.editgroup)
-@app.route('/stats', methods=['GET'])
-def stats_view():
- try:
- stats = api.get_stats()
- except ApiException as ae:
- abort(ae.status)
- return render_template('stats.html', stats=stats.extra)
-
### Search ##################################################################
@app.route('/release/search', methods=['GET', 'POST'])
diff --git a/python/fatcat_web/templates/stats.html b/python/fatcat_web/templates/stats.html
deleted file mode 100644
index 6a37dcee..00000000
--- a/python/fatcat_web/templates/stats.html
+++ /dev/null
@@ -1,104 +0,0 @@
-{% extends "base.html" %}
-{% block body %}
-
-<h1>Entity Statistics</h1>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.entity_counts.work }}
- </div>
- <div class="label">
- Works
- </div>
-</div>
-
-<br>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.entity_counts.release }}
- </div>
- <div class="label">
- Releases
- </div>
-</div>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.releases_with_dois }}
- </div>
- <div class="label">
- ... with DOIs
- </div>
-</div>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.releases_with_dois }}
- </div>
- <div class="label">
- ... with a File
- </div>
-</div>
-
-<br>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.entity_counts.container }}
- </div>
- <div class="label">
- Containers
- </div>
-</div>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.containers_with_issnls }}
- </div>
- <div class="label">
- ... with an ISSN-L
- </div>
-</div>
-
-<br>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.entity_counts.creator }}
- </div>
- <div class="label">
- Creators
- </div>
-</div>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.creators_with_orcids }}
- </div>
- <div class="label">
- ... with an ORCID
- </div>
-</div>
-
-<br>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.entity_counts.file }}
- </div>
- <div class="label">
- Files
- </div>
-</div>
-
-<div class="ui statistic">
- <div class="value">
- {{ stats.files_with_releases }}
- </div>
- <div class="label">
- ... with a Release
- </div>
-</div>
-
-{% endblock %}
diff --git a/python/tests/codegen_tests/test_default_api.py b/python/tests/codegen_tests/test_default_api.py
index 1fcd42d2..8942490b 100644
--- a/python/tests/codegen_tests/test_default_api.py
+++ b/python/tests/codegen_tests/test_default_api.py
@@ -323,12 +323,6 @@ class TestDefaultApi(unittest.TestCase):
"""
pass
- def test_get_stats(self):
- """Test case for get_stats
-
- """
- pass
-
def test_get_work(self):
"""Test case for get_work
diff --git a/python/tests/codegen_tests/test_stats_response.py b/python/tests/codegen_tests/test_stats_response.py
deleted file mode 100644
index e787cd98..00000000
--- a/python/tests/codegen_tests/test_stats_response.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# coding: utf-8
-
-"""
- fatcat
-
- A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501
-
- OpenAPI spec version: 0.1.0
-
- Generated by: https://github.com/swagger-api/swagger-codegen.git
-"""
-
-
-from __future__ import absolute_import
-
-import unittest
-
-import fatcat_client
-from fatcat_client.models.stats_response import StatsResponse # noqa: E501
-from fatcat_client.rest import ApiException
-
-
-class TestStatsResponse(unittest.TestCase):
- """StatsResponse unit test stubs"""
-
- def setUp(self):
- pass
-
- def tearDown(self):
- pass
-
- def testStatsResponse(self):
- """Test StatsResponse"""
- # FIXME: construct object with mandatory attributes with example values
- # model = fatcat_client.models.stats_response.StatsResponse() # noqa: E501
- pass
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/python/tests/routes.py b/python/tests/routes.py
index 2e208d22..bca7cc0f 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -114,6 +114,3 @@ def test_all_views(app):
rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/changelog')
assert rv.status_code == 200
-
- rv = app.get('/stats')
- assert rv.status_code == 200
diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md
index 06d32720..446742be 100644
--- a/rust/fatcat-api-spec/README.md
+++ b/rust/fatcat-api-spec/README.md
@@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
- API version: 0.1.0
-- Build date: 2018-12-24T23:35:32.113Z
+- Build date: 2018-12-25T00:18:05.291Z
This autogenerated project defines an API crate `fatcat` which contains:
* An `Api` trait defining the API in Rust.
@@ -81,7 +81,6 @@ cargo run --example client LookupCreator
cargo run --example client UpdateCreator
cargo run --example client GetEditor
cargo run --example client GetEditorChangelog
-cargo run --example client GetStats
cargo run --example client AcceptEditgroup
cargo run --example client CreateEditgroup
cargo run --example client GetChangelog
diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml
index b514da49..018b58e9 100644
--- a/rust/fatcat-api-spec/api.yaml
+++ b/rust/fatcat-api-spec/api.yaml
@@ -416,12 +416,6 @@ definitions:
additionalProperties: {}
role:
type: string
- stats_response:
- type: object
- properties:
- extra:
- type: object
- additionalProperties: {}
x-entity-responses: &ENTITYRESPONSES
400:
@@ -1910,20 +1904,3 @@ paths:
description: Generic Error
schema:
$ref: "#/definitions/error_response"
- /stats:
- get:
- operationId: "get_stats"
- parameters:
- - name: more
- in: query
- type: string
- required: false
- responses:
- 200:
- description: Success
- schema:
- $ref: "#/definitions/stats_response"
- 500:
- description: Generic Error
- schema:
- $ref: "#/definitions/error_response"
diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml
index 610c8193..141841f4 100644
--- a/rust/fatcat-api-spec/api/swagger.yaml
+++ b/rust/fatcat-api-spec/api/swagger.yaml
@@ -4135,40 +4135,6 @@ paths:
path: "/changelog/:index"
HttpMethod: "Get"
httpmethod: "get"
- /stats:
- get:
- operationId: "get_stats"
- parameters:
- - name: "more"
- in: "query"
- required: false
- type: "string"
- formatString: "{:?}"
- example: "Some(\"more_example\".to_string())"
- responses:
- 200:
- description: "Success"
- schema:
- $ref: "#/definitions/stats_response"
- x-responseId: "Success"
- x-uppercaseResponseId: "SUCCESS"
- uppercase_operation_id: "GET_STATS"
- uppercase_data_type: "STATSRESPONSE"
- producesJson: true
- 500:
- description: "Generic Error"
- schema:
- $ref: "#/definitions/error_response"
- x-responseId: "GenericError"
- x-uppercaseResponseId: "GENERIC_ERROR"
- uppercase_operation_id: "GET_STATS"
- uppercase_data_type: "ERRORRESPONSE"
- producesJson: true
- operation_id: "get_stats"
- uppercase_operation_id: "GET_STATS"
- path: "/stats"
- HttpMethod: "Get"
- httpmethod: "get"
definitions:
error_response:
type: "object"
@@ -5206,14 +5172,6 @@ definitions:
creator_id: "creator_id"
index: 1
upperCaseName: "RELEASE_CONTRIB"
- stats_response:
- type: "object"
- properties:
- extra:
- type: "object"
- example:
- extra: "{}"
- upperCaseName: "STATS_RESPONSE"
file_entity_urls:
required:
- "rel"
diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs
index 348666dc..34131db7 100644
--- a/rust/fatcat-api-spec/examples/client.rs
+++ b/rust/fatcat-api-spec/examples/client.rs
@@ -18,7 +18,7 @@ use fatcat::{
DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse,
GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse,
GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse,
- GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse,
+ GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetWorkEditResponse,
GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse,
};
@@ -52,7 +52,6 @@ fn main() {
"LookupCreator",
"GetEditor",
"GetEditorChangelog",
- "GetStats",
"AcceptEditgroup",
"GetChangelog",
"GetChangelogEntry",
@@ -261,11 +260,6 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("GetStats") => {
- let result = client.get_stats(Some("more_example".to_string())).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
Some("AcceptEditgroup") => {
let result = client.accept_editgroup("editgroup_id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs
index 62ec88b8..bbd00b83 100644
--- a/rust/fatcat-api-spec/examples/server_lib/server.rs
+++ b/rust/fatcat-api-spec/examples/server_lib/server.rs
@@ -17,7 +17,7 @@ use fatcat::{
GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse,
GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse,
GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse,
- GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse,
+ GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse,
GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse,
UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse,
};
@@ -305,12 +305,6 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_stats(&self, more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_stats({:?}) - X-Span-ID: {:?}", more, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs
index eddd99fa..1898f0b5 100644
--- a/rust/fatcat-api-spec/src/client.rs
+++ b/rust/fatcat-api-spec/src/client.rs
@@ -41,7 +41,7 @@ use {
GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse,
GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse,
GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse,
- GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse,
+ GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse,
GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse,
UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse,
};
@@ -1935,55 +1935,6 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn get_stats(&self, param_more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_more = param_more.map_or_else(String::new, |query| format!("more={more}&", more = query.to_string()));
-
- let url = format!("{}/v0/stats?{more}", self.base_path, more = utf8_percent_encode(&query_more, QUERY_ENCODE_SET));
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetStatsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::StatsResponse>(&buf)?;
-
- Ok(GetStatsResponse::Success(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetStatsResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
fn accept_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editgroup/{editgroup_id}/accept",
diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs
index ba578224..4ba734b1 100644
--- a/rust/fatcat-api-spec/src/lib.rs
+++ b/rust/fatcat-api-spec/src/lib.rs
@@ -333,14 +333,6 @@ pub enum GetEditorChangelogResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetStatsResponse {
- /// Success
- Success(models::StatsResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
pub enum AcceptEditgroupResponse {
/// Merged Successfully
MergedSuccessfully(models::Success),
@@ -881,8 +873,6 @@ pub trait Api {
fn get_editor_changelog(&self, editor_id: String, context: &Context) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send>;
- fn get_stats(&self, more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send>;
-
fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
@@ -1067,8 +1057,6 @@ pub trait ApiNoContext {
fn get_editor_changelog(&self, editor_id: String) -> Box<Future<Item = GetEditorChangelogResponse, Error = ApiError> + Send>;
- fn get_stats(&self, more: Option<String>) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send>;
-
fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
@@ -1302,10 +1290,6 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().get_editor_changelog(editor_id, &self.context())
}
- fn get_stats(&self, more: Option<String>) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
- self.api().get_stats(more, &self.context())
- }
-
fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
self.api().accept_editgroup(editgroup_id, &self.context())
}
diff --git a/rust/fatcat-api-spec/src/mimetypes.rs b/rust/fatcat-api-spec/src/mimetypes.rs
index b94aa6f6..20d3331c 100644
--- a/rust/fatcat-api-spec/src/mimetypes.rs
+++ b/rust/fatcat-api-spec/src/mimetypes.rs
@@ -404,14 +404,6 @@ pub mod responses {
lazy_static! {
pub static ref GET_EDITOR_CHANGELOG_GENERIC_ERROR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the response content types for GetStats
- lazy_static! {
- pub static ref GET_STATS_SUCCESS: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetStats
- lazy_static! {
- pub static ref GET_STATS_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the response content types for AcceptEditgroup
lazy_static! {
pub static ref ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY: Mime = mime!(Application / Json);
diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs
index d640be42..8f3e525a 100644
--- a/rust/fatcat-api-spec/src/models.rs
+++ b/rust/fatcat-api-spec/src/models.rs
@@ -723,19 +723,6 @@ impl ReleaseRef {
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct StatsResponse {
- #[serde(rename = "extra")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
-}
-
-impl StatsResponse {
- pub fn new() -> StatsResponse {
- StatsResponse { extra: None }
- }
-}
-
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Success {
#[serde(rename = "message")]
pub message: String,
diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs
index 6dec84b9..51b1ac45 100644
--- a/rust/fatcat-api-spec/src/server.rs
+++ b/rust/fatcat-api-spec/src/server.rs
@@ -43,7 +43,7 @@ use {
GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse,
GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse,
GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetReleaseEditResponse,
- GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetStatsResponse, GetWorkEditResponse, GetWorkHistoryResponse,
+ GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse,
GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse,
UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse,
};
@@ -2507,64 +2507,6 @@ where
);
let api_clone = api.clone();
- router.get(
- "/v0/stats",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_more = query_params.get("more").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
-
- match api.get_stats(param_more, context).wait() {
- Ok(rsp) => match rsp {
- GetStatsResponse::Success(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_STATS_SUCCESS.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetStatsResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_STATS_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "GetStats",
- );
-
- let api_clone = api.clone();
router.post(
"/v0/editgroup/:editgroup_id/accept",
move |req: &mut Request| {
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 99db91c0..5b95f149 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -349,7 +349,11 @@ impl Server {
})
}
- pub fn get_editgroup_handler(&self, editgroup_id: FatCatId, conn: &DbConn) -> Result<Editgroup> {
+ pub fn get_editgroup_handler(
+ &self,
+ editgroup_id: FatCatId,
+ conn: &DbConn,
+ ) -> Result<Editgroup> {
let row: EditgroupRow = editgroup::table.find(editgroup_id.to_uuid()).first(conn)?;
let edits = EditgroupEdits {
@@ -474,84 +478,6 @@ impl Server {
Ok(entry)
}
- pub fn get_stats_handler(&self, more: &Option<String>, conn: &DbConn) -> Result<StatsResponse> {
- let merged_editgroups: i64 = changelog::table
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let releases_with_dois: i64 = release_rev::table
- .inner_join(release_ident::table)
- .filter(release_rev::doi.is_not_null())
- .filter(release_ident::is_live.eq(true))
- .filter(release_ident::redirect_id.is_null())
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let creators_with_orcids: i64 = creator_rev::table
- .inner_join(creator_ident::table)
- .filter(creator_rev::orcid.is_not_null())
- .filter(creator_ident::is_live.eq(true))
- .filter(creator_ident::redirect_id.is_null())
- .select(diesel::dsl::count_star())
- .first(conn)?;
- let containers_with_issnls: i64 = container_rev::table
- .inner_join(container_ident::table)
- .filter(container_rev::issnl.is_not_null())
- .filter(container_ident::is_live.eq(true))
- .filter(container_ident::redirect_id.is_null())
- .count()
- .first(conn)?;
-
- let files_with_releases: Option<i64> = if more.is_some() {
- // this query is slightly inaccurate and over-counts: it includes files that have release
- // links only to inactive releases
- Some(
- file_rev::table
- .inner_join(file_ident::table)
- .inner_join(file_release::table)
- .filter(file_ident::is_live.eq(true))
- .filter(file_ident::redirect_id.is_null())
- .select(file_ident::id)
- .distinct()
- .count()
- .first(conn)?,
- )
- } else {
- None
- };
- let releases_with_files: Option<i64> = if more.is_some() {
- // this slightly overcounts also: it will include releases which are only linked to from
- // inactive files
- Some(
- release_ident::table
- .inner_join(file_release::table)
- .filter(release_ident::is_live.eq(true))
- .filter(release_ident::redirect_id.is_null())
- .select(file_release::target_release_ident_id)
- .distinct()
- .count()
- .first(conn)?,
- )
- } else {
- None
- };
-
- let val = json!({
- "entity_counts": {
- "container": count_entity!(container_ident, conn),
- "creator": count_entity!(creator_ident, conn),
- "file": count_entity!(file_ident, conn),
- "release": count_entity!(release_ident, conn),
- "work": count_entity!(work_ident, conn),
- },
- "merged_editgroups": merged_editgroups,
- "releases_with_dois": releases_with_dois,
- "creators_with_orcids": creators_with_orcids,
- "containers_with_issnls": containers_with_issnls,
- "files_with_releases": files_with_releases,
- "releases_with_files": releases_with_files,
- });
- Ok(StatsResponse { extra: Some(val) })
- }
-
entity_batch_handler!(create_container_batch_handler, ContainerEntity);
entity_batch_handler!(create_creator_batch_handler, CreatorEntity);
entity_batch_handler!(create_file_batch_handler, FileEntity);
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index ed4053b9..85b698aa 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -914,23 +914,4 @@ impl Api for Server {
};
Box::new(futures::done(Ok(ret)))
}
-
- fn get_stats(
- &self,
- more: Option<String>,
- _context: &Context,
- ) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
- let conn = self.db_pool.get().expect("db_pool error");
- // No transaction for GET
- let ret = match self.get_stats_handler(&more, &conn) {
- Ok(stats) => GetStatsResponse::Success(stats),
- Err(e) => {
- error!("{}", e);
- GetStatsResponse::GenericError(ErrorResponse {
- message: e.to_string(),
- })
- }
- };
- Box::new(futures::done(Ok(ret)))
- }
}
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index 86559545..6e4adda6 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -841,26 +841,6 @@ fn test_changelog() {
}
#[test]
-fn test_stats() {
- let (headers, router, _conn) = setup_http();
-
- check_http_response(
- request::get("http://localhost:9411/v0/stats", headers.clone(), &router),
- status::Ok,
- Some("merged_editgroups"),
- );
- check_http_response(
- request::get(
- "http://localhost:9411/v0/stats?more=yes",
- headers.clone(),
- &router,
- ),
- status::Ok,
- Some("merged_editgroups"),
- );
-}
-
-#[test]
fn test_400() {
let (headers, router, _conn) = setup_http();