Skip to content

Commit 3d04ca8

Browse files
committed
docs: update README
1 parent 59b6486 commit 3d04ca8

File tree

1 file changed

+129
-68
lines changed

1 file changed

+129
-68
lines changed

README.md

Lines changed: 129 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,121 +2,182 @@
22

33
# ckanext-scientometrics
44

5-
**TODO:** Put a description of your extension here: What does it do? What features does it have? Consider including some screenshots or embedding a video!
5+
Scientometrics metrics for CKAN users. The extension lets you:
66

7+
- store author identifiers (per source) in user extras (`plugin_extras`)
8+
- fetch author-level metrics from external providers
9+
- persist fetched metrics in dedicated DB tables
10+
- display selected metrics on the user page
711

8-
## Requirements
12+
Supported sources (as implemented):
913

10-
**TODO:** For example, you might want to mention here which versions of CKAN this
11-
extension works with.
14+
- Google Scholar (author profile metrics)
15+
- Semantic Scholar (author metrics)
16+
- OpenAlex (author metrics)
1217

13-
If your extension works across different versions you can add the following table:
18+
## How it works
1419

15-
Compatibility with core CKAN versions:
20+
- User author identifiers are stored in the user `plugin_extras` under `scim`:
21+
keys like `<source>_author_id` (e.g. `google_scholar_author_id`).
22+
- Metrics are fetched via per-source extractors and stored in:
23+
- `scim_user_metric` (per user + source)
24+
- `scim_dataset_metric` (reserved for dataset metrics; currently only model/migration exist)
25+
- The user page template can render cards for enabled sources using the stored metrics.
1626

17-
| CKAN version | Compatible? |
18-
| --------------- | ------------- |
19-
| 2.6 and earlier | not tested |
20-
| 2.7 | not tested |
21-
| 2.8 | not tested |
22-
| 2.9 | not tested |
27+
## Usage
2328

24-
Suggested values:
29+
### 1) Configure enabled sources
2530

26-
* "yes"
27-
* "not tested" - I can't think of a reason why it wouldn't work
28-
* "not yet" - there is an intention to get it working
29-
* "no"
31+
Enable the plugin in CKAN config:
3032

33+
```ini
34+
ckan.plugins = ... scientometrics
35+
```
3136

32-
## Installation
37+
Configure which metric sources are enabled:
3338

34-
**TODO:** Add any additional install steps to the list below.
35-
For example installing any non-Python dependencies or adding any required
36-
config settings.
39+
```ini
40+
ckanext.scientometrics.enabled_metrics = google_scholar semantic_scholar openalex
41+
ckanext.scientometrics.show_on_user_page = true
42+
```
3743

38-
To install ckanext-scientometrics:
44+
### 2) Add author IDs to a user
3945

40-
1. Activate your CKAN virtual environment, for example:
46+
In the user edit form, the extension adds extra fields (one per enabled source).
47+
The values are stored under `plugin_extras["scim"]` as:
4148

42-
. /usr/lib/ckan/default/bin/activate
49+
- `google_scholar_author_id`
50+
- `semantic_scholar_author_id`
51+
- `openalex_author_id`
4352

44-
2. Clone the source and install it on the virtualenv
53+
### 3) Update metrics for a user (action)
4554

46-
git clone https://github.com/aleks-iv/ckanext-scientometrics.git
47-
cd ckanext-scientometrics
48-
pip install -e .
49-
pip install -r requirements.txt
55+
The extension provides actions to fetch and store metrics. A typical call:
5056

51-
3. Add `scientometrics` to the `ckan.plugins` setting in your CKAN
52-
config file (by default the config file is located at
53-
`/etc/ckan/default/ckan.ini`).
57+
- `scim_update_user_metrics` with:
58+
- `user_id` (id or name)
59+
- `requested_sources` (optional list of sources; defaults to enabled sources)
5460

55-
4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
61+
Stored records are keyed by `(user_id, source)` in `scim_user_metric`.
5662

57-
sudo service apache2 reload
63+
To retrieve stored metrics:
5864

65+
- `scim_get_user_metrics` with:
66+
- `user_id`
5967

60-
## Config settings
68+
Returns a dict keyed by `source`, where each value is built from the stored JSON metrics
69+
plus metadata like status and external references (when present).
6170

62-
None at present
71+
### 4) Update metrics for all users (CLI)
6372

64-
**TODO:** Document any optional config settings here. For example:
73+
The extension exposes a CLI command:
6574

66-
# The minimum number of hours to wait before re-checking a resource
67-
# (optional, default: 24).
68-
ckanext.scientometrics.some_setting = some_default_value
75+
```bash
76+
ckan scim update-user-metrics
77+
```
6978

79+
Options:
7080

71-
## Developer installation
81+
- `--user-ids <id>` (repeatable): update only specified user IDs
82+
- `--requested-sources <source>` (repeatable): update only specified sources
7283

73-
To install ckanext-scientometrics for development, activate your CKAN virtualenv and
74-
do:
84+
If no `--user-ids` are provided, it updates all users.
7585

76-
git clone https://github.com/aleks-iv/ckanext-scientometrics.git
77-
cd ckanext-scientometrics
78-
python setup.py develop
79-
pip install -r dev-requirements.txt
86+
## Database
8087

88+
This extension creates two tables:
8189

82-
## Tests
90+
- `scim_user_metric`
91+
- unique constraint: `(user_id, source)`
92+
- stores:
93+
- `metrics` (JSONB)
94+
- `external_id`, `external_url`
95+
- `status`
96+
- timestamps
97+
- `extras` (JSONB for future metadata)
98+
99+
- `scim_dataset_metric`
100+
- unique constraint: `(package_id, source)`
101+
- same structure as user metrics table
102+
103+
Foreign keys are configured with `ondelete="CASCADE"`.
104+
105+
## Requirements
106+
107+
Compatibility with core CKAN versions:
108+
109+
| CKAN version | Compatible? |
110+
| --------------- | ------------- |
111+
| 2.9 and earlier | no |
112+
| 2.10+ | yes |
83113

84-
To run the tests, do:
114+
(Tests run in CI on a CKAN 2.11 container.)
85115

86-
pytest --ckan-ini=test.ini
116+
## Installation
87117

118+
To install ckanext-scientometrics:
88119

89-
## Releasing a new version of ckanext-scientometrics
120+
1. Activate your CKAN virtual environment, for example:
90121

91-
If ckanext-scientometrics should be available on PyPI you can follow these steps to publish a new version:
122+
```bash
123+
. /usr/lib/ckan/default/bin/activate
124+
```
92125

93-
1. Update the version number in the `setup.py` file. See [PEP 440](http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers) for how to choose version numbers.
126+
2. Clone the source and install it on the virtualenv:
94127

95-
2. Make sure you have the latest version of necessary packages:
128+
```bash
129+
git clone https://github.com/aleks-iv/ckanext-scientometrics.git
130+
cd ckanext-scientometrics
131+
pip install -e .
132+
pip install -r requirements.txt
133+
```
96134

97-
pip install --upgrade setuptools wheel twine
135+
3. Add `scientometrics` to the `ckan.plugins` setting in your CKAN config file
136+
(by default `/etc/ckan/default/ckan.ini`).
98137

99-
3. Create a source and binary distributions of the new version:
138+
4. Restart CKAN (eg on Ubuntu + Apache):
100139

101-
python setup.py sdist bdist_wheel && twine check dist/*
140+
```bash
141+
sudo service apache2 reload
142+
```
102143

103-
Fix any errors you get.
144+
## Config settings
104145

105-
4. Upload the source distribution to PyPI:
146+
- `ckanext.scientometrics.enabled_metrics` (type: list)
147+
- default: `google_scholar semantic_scholar openalex`
148+
- enabled sources; controls which user fields are shown and which sources can be updated
106149

107-
twine upload dist/*
150+
- `ckanext.scientometrics.show_on_user_page` (type: bool)
151+
- default: `true`
152+
- show metrics cards on the user page
108153

109-
5. Commit any outstanding changes:
154+
Example:
110155

111-
git commit -a
112-
git push
156+
```ini
157+
ckan.plugins = ... scientometrics
158+
159+
ckanext.scientometrics.enabled_metrics = openalex semantic_scholar
160+
ckanext.scientometrics.show_on_user_page = true
161+
```
162+
163+
## Developer installation
164+
165+
To install for development:
166+
167+
```bash
168+
git clone https://github.com/aleks-iv/ckanext-scientometrics.git
169+
cd ckanext-scientometrics
170+
pip install -e .
171+
pip install -r dev-requirements.txt
172+
```
173+
174+
## Tests
113175

114-
6. Tag the new release of the project on GitHub with the version number from
115-
the `setup.py` file. For example if the version number in `setup.py` is
116-
0.0.1 then do:
176+
To run tests:
117177

118-
git tag 0.0.1
119-
git push --tags
178+
```bash
179+
pytest --ckan-ini=test.ini
180+
```
120181

121182
## License
122183

0 commit comments

Comments
 (0)