Skip to content

Add UserDictionaryResource (User Presets Step 1) - #1147

Merged
Yicong-Huang merged 6 commits into
masterfrom
Albert-UserDictionaryResource
Jun 19, 2021
Merged

Yicong-Huang merged 6 commits into
masterfrom
Albert-UserDictionaryResource

Conversation

@MysteriousChallenger

@MysteriousChallenger MysteriousChallenger commented Jun 4, 2021 •

Copy link
Copy Markdown
Contributor

This PR is extracted from #1041 as step 1 of the User Preset feature.

rebase of picked commits pertaining to UserDictionaryResource onto master

UserDictionaryResource provides a "dictionary", a persistent collection of string (key, value) pairs for each user.
Its API is located at /api/users/dictionary.

functionality includes get/set/delete, mapped to the GET/POST/DELETE HTTP methods.

Changes from last review (for Yicong)

  • now only consumes and produces application/json
  • CODE 422 Unprocessable Entity replaces 400 bad request if user provides well formed request that cannot be fulfilled
    • I.E well-formed DELETE request when there is nothing to delete
  • No more confusing json validation: key/values are always strings (previously was trying to store them in MySQL json column, now using text column)
  • user/login check first
  • Unused imports removed
  • using orNull instead of getOrElse(null)
  • removed extraneous return

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, please take care of the comments in code.

Comment thread core/scripts/sql/texera_ddl.sql Resolved
Comment thread core/scripts/sql/texera_ddl.sql Resolved
@Yicong-Huang Yicong-Huang changed the title Rebase of UserDictionaryResource onto Master Add UserDictionaryResource Jun 5, 2021
@Yicong-Huang Yicong-Huang changed the title Add UserDictionaryResource Add UserDictionaryResource (Auto-fill Step 1) Jun 5, 2021
@Yicong-Huang Yicong-Huang changed the title Add UserDictionaryResource (Auto-fill Step 1) Add UserDictionaryResource (Autofill Step 1) Jun 5, 2021
@MysteriousChallenger
MysteriousChallenger force-pushed the Albert-UserDictionaryResource branch from b46f6d4 to 64fbe98 Compare June 6, 2021 01:58
@MysteriousChallenger MysteriousChallenger changed the title Add UserDictionaryResource (Autofill Step 1) Add UserDictionaryResource (User Presets Step 1) Jun 6, 2021
@MysteriousChallenger

MysteriousChallenger commented Jun 10, 2021 •

Copy link
Copy Markdown
Contributor Author

Turns out XHR (browser side api for http requests) doesn't allow get requests to have a body, despite generating content-type/length headers and allowing me to do so in the inspector panel (which I had used to test the backend before working on the frontend).

I've changed all the GET requests to POST requests. This also meant I had to change the API path to /users/dictionary/{get|set|delete} for the get set delete operations, since I couldn't differentiate them by http method anymore

adds user_dictionary database table and JOOQ generated DAOs and POJOs
user_dictionary stores uid+key -> json-value pairs, storing arbitrary json data for each user
fixed sql formatting, capitalized error messages, fixed edge case of missing json properties in requests
turns out XHR doesn't allow get requests to have a body, despite generating content-type/length headers and it being allowed in the inspector.
@Yicong-Huang
Yicong-Huang force-pushed the Albert-UserDictionaryResource branch from 0b57e66 to fd4fd97 Compare June 17, 2021 07:56

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general it looks good. it is hard to test as it only contains the backend. Please address some minor comments in code.

@Yicong-Huang
Yicong-Huang merged commit e832c72 into master Jun 19, 2021
@Yicong-Huang
Yicong-Huang deleted the Albert-UserDictionaryResource branch June 19, 2021 01:29
@Yicong-Huang Yicong-Huang mentioned this pull request Jun 26, 2021
2 of 3 tasks
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR is extracted from apache#1041 as step 1 of the User Preset feature. 


rebase of picked commits pertaining to UserDictionaryResource onto master

UserDictionaryResource provides a "_dictionary_", a persistent collection of string (key, value) pairs for each user. 
Its API is located at /api/users/dictionary. 

functionality includes get/set/delete, mapped to the GET/POST/DELETE HTTP methods.

Changes from last review (for Yicong)
 - now only consumes and produces application/json
 - CODE 422 Unprocessable Entity replaces 400 bad request if user provides well formed request that cannot be fulfilled
    - I.E well-formed DELETE request when there is nothing to delete
 - No more confusing json validation: key/values are always strings (previously was trying to store them in MySQL json column, now using text column)
 - user/login check first
 - Unused imports removed
 - using orNull instead of getOrElse(null)
 - removed extraneous _return_

Co-authored-by: Yicong Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants