Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should the user object in GetSiteResponse use ListingType/SortType enums? #1136

Closed
eiknat opened this issue Sep 15, 2020 · 4 comments · Fixed by #2808
Closed

should the user object in GetSiteResponse use ListingType/SortType enums? #1136

eiknat opened this issue Sep 15, 2020 · 4 comments · Fixed by #2808
Labels

Comments

@eiknat
Copy link
Contributor

eiknat commented Sep 15, 2020

default_sort_type and default_listing_type both currently return numbers, should or will these be returning the same enum values used in other endpoints?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@dessalines
Copy link
Member

For now at least, consider these as numbered enums (This comes from them being the only sorting type stored in the DB, and I think I arbitrarily chose smallint as a way to store them). Unfortunately all the other types are string enums, and serialized that way.

Eventually it'd probably be a good idea to have these ones be strings as well, so it would require changing both the API and that column to a varchar type.

@eiknat
Copy link
Contributor Author

eiknat commented Sep 18, 2020

okay, thanks! i'll see if i can write a serializer for it that can accept both

@dessalines
Copy link
Member

I would just let the serializer treat it like a number enum, and then the clients can use the index / ordinal of the value:

  handleUserSettingsListingTypeChange(val: ListingType) {
    this.state.userSettingsForm.default_listing_type = Object.keys(
      ListingType
    ).indexOf(val);
    this.setState(this.state);
  }

In the future we can convert it to a string-valued enum anyway.

@Nutomic Nutomic added enhancement New feature or request extra: good first issue Good for newcomers and removed type: question General question labels Jan 15, 2023
@dessalines
Copy link
Member

This could be done using: https://github.com/adwhit/diesel-derive-enum . The only other enum that's in use, is RegistrationMode

dessalines added a commit that referenced this issue Apr 15, 2023
- Uses diesel-derive-enum.
- Adds diesel.toml , so we can again use the auto-generated schema.rs
- Fixes a lot of DB null issues and column ordering issues.
- Fixes #1136
- Also replaces RegistrationMode boilerplate.
dessalines added a commit that referenced this issue Apr 17, 2023
* Adding diesel enums for SortType and ListingType

- Uses diesel-derive-enum.
- Adds diesel.toml , so we can again use the auto-generated schema.rs
- Fixes a lot of DB null issues and column ordering issues.
- Fixes #1136
- Also replaces RegistrationMode boilerplate.

* Fixing unit tests 1.

* Remove comment line.

* Before patch.

* Before again.

* Using patch file to fix diesel_ltree issue with diesel.toml

* Adding some yalc ignores

* Fixing RegistrationMode enums

* Adding woodpecker diesel schema check.

* Try adding openssl 1.

* Try using diesel-cli image 1

* Try using diesel-cli image 2

* Try using diesel-cli image 3

* Try using diesel-cli image 4

* Try using diesel-cli image 5

* Try using diesel-cli image 6

* Try using diesel-cli image 7

* Try using diesel-cli image 8

* Try using diesel-cli image 9

* Try using diesel-cli image 10

* Try using diesel-cli image 11

* Try using diesel-cli image 12

* Try using diesel-cli image 13
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 a pull request may close this issue.

3 participants