Skip to content

Conversation

@70ray
Copy link
Collaborator

@70ray 70ray commented Nov 30, 2024

Sandbox at: https://www.pgdp.org/~rp31/c.branch/api_wc3

There are two endpoints:

  • PUT v1/projects/:projectid/wordcheck This does not require the user to own the page. Needs accepted words and languages. Returns an array of bad words with their levels.
  • PUT v1/projects/:projectid/pages/:pagename/wordcheck. [edited] This requires the user to own the page and executes save_wordcheck_event(). The logic of when to call this is left to the client. It can be as follows: When the user does any kind of save, if he has previously entered wordcheck mode and a wordcheck report has not previously been submitted then submit a report before the save even if the user has not suggested any words to be accepted. On any subsequent saves submit a report only if the user has suggested some words since the previous report and include only these words. In this way the same word will not be reported more than once for each page.

@70ray 70ray requested review from chrismiceli and cpeel November 30, 2024 20:13
@70ray
Copy link
Collaborator Author

70ray commented Dec 2, 2024

Sandbox updated

@cpeel
Copy link
Member

cpeel commented Dec 7, 2024

@70ray - can you please update your sandbox?

@cpeel
Copy link
Member

cpeel commented Dec 7, 2024

The v1/projects/:projectid/wordcheck endpoint is looking great.

Some samples for other reviewers.

Example files:

cpeel@test:~$ cat data.json
{
    "text": "one two uno four, arid"
}
cpeel@test:~$ cat data_with_language.json
{
    "text": "one two uno four, arid",
    "languages": ["Spanish", "English"]
}
cpeel@test:~$ cat data_with_accepted.json
{
    "text": "one two uno four, arid",
    "accepted_words": ["uno"]
}

API calls:

export API_KEY=review
curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
     -d @data.json \
     -X PUT "https://www.pgdp.org/~rp31/c.branch/api_wc3/api/v1/projects/projectID45c225f598e32/wordcheck"

curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
     -d @data_with_language.json \
     -X PUT "https://www.pgdp.org/~rp31/c.branch/api_wc3/api/v1/projects/projectID45c225f598e32/wordcheck"

curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
     -d @data_with_accepted.json \
     -X PUT "https://www.pgdp.org/~rp31/c.branch/api_wc3/api/v1/projects/projectID45c225f598e32/wordcheck"

@70ray
Copy link
Collaborator Author

70ray commented Dec 7, 2024

@70ray - can you please update your sandbox?

Sandbox updated now.

@cpeel cpeel requested a review from srjfoo December 7, 2024 22:36
Copy link
Member

@cpeel cpeel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v1/projects/{projectid}/pages/{pagename}/wordcheck also looks good. I tested it with a page I wasn't allowed to change, one that I was but in the wrong state, and one that I was and had checked out.

Sample data files:

cpeel@test:~$ cat wc_report.json
{
}
cpeel@test:~$ cat wc_report_accepted.json
{
    "accepted_words": ["uno"]
}

And API calls I used -- note that you have to have the page saved as in-progress by the user with the API key for this to work or you'll (correctly) get errors.

export API_KEY=something
curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
     -d @wc_report.json \
     -X PUT "https://www.pgdp.org/~rp31/c.branch/api_wc3/api/v1/projects/projectID45c225f598e32/pages/123.png/wordcheck"

curl -i -H "Accept: application/json" -H "X-API-KEY: $API_KEY" \
     -d @wc_report_accepted.json \
     -X PUT "https://www.pgdp.org/~rp31/c.branch/api_wc3/api/v1/projects/projectID45c225f598e32/pages/123.png/wordcheck"

@srjfoo
Copy link
Member

srjfoo commented Dec 8, 2024

The v1/projects/{projectid}/pages/{pagename}/wordcheck also looks good. I tested it with a page I wasn't allowed to change, one that I was but in the wrong state, and one that I was and had checked out.

I used your examples, customized for myself, but I'm not entirely sure what sort of data I should have in my file, or what results I should be getting on success.

@cpeel
Copy link
Member

cpeel commented Dec 8, 2024

The v1/projects/{projectid}/pages/{pagename}/wordcheck also looks good. I tested it with a page I wasn't allowed to change, one that I was but in the wrong state, and one that I was and had checked out.

I used your examples, customized for myself, but I'm not entirely sure what sort of data I should have in my file, or what results I should be getting on success.

This endpoint is inserting records into the wordcheck_events table. You can query the table for the most recent events for your user with:

select * from wordcheck_events where username='srjfoo' order by timestamp desc limit 10;

The accepted_words in the API call should show up in the suggestions column.

@srjfoo
Copy link
Member

srjfoo commented Dec 8, 2024

This endpoint is inserting records into the wordcheck_events table. You can query the table for the most recent events for your user with:

select * from wordcheck_events where username='srjfoo' order by timestamp desc limit 10;

The accepted_words in the API call should show up in the suggestions column.

Thanks, this was exactly what I needed!

@cpeel cpeel merged commit 349b6e1 into DistributedProofreaders:master Dec 8, 2024
12 checks passed
@70ray 70ray deleted the api_wc3 branch December 10, 2024 08:29
@cpeel cpeel mentioned this pull request Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants