Skip to content

Conversation

@dukenguyenxyz
Copy link

Changes:

  • Expand coverage to all existing rest-api routes and controller actions, accompanied by specs
  • Add some generic modules for frequently used methods
  • Remove all predefined models from placeos-models with autogenerated model macro

GabFitzgerald and others added 30 commits October 26, 2020 12:49
…odules to correspond to all rest-api controller actions
… ref, comment where fields are missing, or do not exist in original model
feat: expand controller action coverage, with specs
Copy link
Contributor

@caspiano caspiano left a comment

Choose a reason for hiding this comment

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

Also noticed that some .DS_STORE files have made it in

Comment on lines 48 to 71
nickname : String? = "",
email : String? = "",
phone : String? = "",
country : String? = "",
image : String? = "",
ui_theme : String? = "light",
metadata : String? = "",
login_name : String? = "",
staff_id : String? = "",
first_name : String? = "",
last_name : String? = "",
building : String? = "",
password_digest : String? = "",
email_digest : String? = "",
card_number : String? = "",
deleted : Bool? = false,
groups : Array(String)? = [] of String,
access_token : String? = "",
refresh_token : String? = "",
expires_at : Int64? = nil,
expires : Bool? = false,
password : String? = "",
sys_admin : Bool? = false,
support : Bool? = false
Copy link
Contributor

Choose a reason for hiding this comment

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

best to have these as nil defaults, or perhaps even do the Undefined type trick so you don't serialise the nil, which may be acceptable for the attribute and lead to an accidental override

Comment on lines +54 to +62
module Create(T)
def create(**args) : T
post base, body: from_args, as: T
end
end

module Update(T)
def update(id, **args) : T
post "#{base}/#{id}", body: from_args, as: T
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps we can pair on this?

Comment on lines +14 to +31
# List or search.
#
# Results maybe filtered by specifying a query - *q* - to search across
# attributes. A small query language is supported within this:
#
# Operator | Action
# -------- | ------
# `+` | Matches both terms
# `|` | Matches either terms
# `-` | Negates a single token
# `"` | Wraps tokens to form a phrase
# `(` `)` | Provides precedence
# `~N` | Specifies edit distance (fuzziness) after a word
# `~N` | Specifies slop amount (deviation) after a phrase
#
# Up to *limit* will be returned, with a paging based on *offset*.
module Search(T)
def search(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# List or search.
#
# Results maybe filtered by specifying a query - *q* - to search across
# attributes. A small query language is supported within this:
#
# Operator | Action
# -------- | ------
# `+` | Matches both terms
# `|` | Matches either terms
# `-` | Negates a single token
# `"` | Wraps tokens to form a phrase
# `(` `)` | Provides precedence
# `~N` | Specifies edit distance (fuzziness) after a word
# `~N` | Specifies slop amount (deviation) after a phrase
#
# Up to *limit* will be returned, with a paging based on *offset*.
module Search(T)
def search(
module Search(T)
# List or search.
#
# Results maybe filtered by specifying a query - *q* - to search across
# attributes. A small query language is supported within this:
#
# Operator | Action
# -------- | ------
# `+` | Matches both terms
# `|` | Matches either terms
# `-` | Negates a single token
# `"` | Wraps tokens to form a phrase
# `(` `)` | Provides precedence
# `~N` | Specifies edit distance (fuzziness) after a word
# `~N` | Specifies slop amount (deviation) after a phrase
#
# Up to *limit* will be returned, with a paging based on *offset*.
def search(

end

def compiled(id : String)
get "#{base}/#{id}/compiled", as: Driver
Copy link
Contributor

Choose a reason for hiding this comment

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

this will be either 404 or 200, so just return a bool

def create(
name : String,
role : Role,
role : Int32,
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have this using an explicit enum.

try making an alias to the actual enum where you generate the models

@@ -1,5 +1,5 @@
require "../endpoint"
require "../../api/models/auths/*"
require "placeos-models"
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this required here?

{% if opts[:converter] && !FORBID_CONVERTERS.includes?(opts[:converter].resolve.stringify) %}
@[JSON::Field(converter: {{opts[:converter]}})]
{% end %}
property {{name.id}} : {{opts[:klass]}}?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
property {{name.id}} : {{opts[:klass]}}?
getter {{name.id}} : {{opts[:klass]}}?

you also have access to the actual type of the attribute here, might be good to use that directly rather than making all getters nillable.

for routes that return extra results, you can make them nillable fields. for example

Comment on lines +24 to +26
{% if subclasses == PlaceOS::Model::SubModel %}
include Timestamps
{% end %}
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this is a false assumption

include Timestamps
{% end %}

getter id : String? = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

the id should be non-nil

@caspiano caspiano marked this pull request as draft March 9, 2022 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: low type: enhancement new feature or request type: maintenance requires maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants