added bills dataservice - #8
Conversation
|
Amazing! |
…vice - work in progress
| ("name", KnessetDataServiceSimpleField('Name', "string", "bill heb name")), | ||
| ("type_id", KnessetDataServiceSimpleField('SubTypeID', "integer", "type id of the bill")), | ||
| ("type_description", | ||
| KnessetDataServiceSimpleField('SubTypeDesc', "string", "type description of the bill")), |
There was a problem hiding this comment.
the new knesset API have a lot of these fields where you have somethingID and related somethingDesc
worth to create a new KnessetDataServiceField class which will handle it automatically -
so instead of defining those two fields, you would define only 1 field:
("type", KnessetDataServiceIdDescriptionField("SubType", "type of the bill"))
behind the scenes this field can expose a python tuple of (id, description)
| ("num", KnessetDataServiceSimpleField('Number', "Integer",)), | ||
| ("postponent_reason_id", KnessetDataServiceSimpleField('PostponementReasonID', | ||
| "Integer",)), | ||
| ("postponent_reason_desc", KnessetDataServiceSimpleField('PostponementReasonDesc', "string",)), |
There was a problem hiding this comment.
this is another example of the joined Id/desc field
| ("type_description", | ||
| KnessetDataServiceSimpleField('SubTypeDesc', "string", "type description of the bill")), | ||
| ("private_num", KnessetDataServiceSimpleField('PrivateNumber', "integer",)), | ||
| ("committee_id", KnessetDataServiceSimpleField('CommitteeID', "integer",)), |
There was a problem hiding this comment.
this id field is related to Committee object
for this case you can add a helper method on your object which will try to fetch the related committe
something like this:
def get_committee(self):
return Committee.get(self.committee_id)There was a problem hiding this comment.
maybe it's worth to create a new class for this type of fields
something like:
("committee", KnessetdataServiceRelatedField("CommitteeID", dataservice_class=Committee))
which will handle it automatically
but need to make sure by default it doesn't fetch the related object - only when user requests it
so I'm not sure what's the best way to implement it..
There was a problem hiding this comment.
the get_committee function will be done
regarding the field type, will be done in #14
|
I will take all the points that you mentioned into my consideration
…On Sat, Apr 1, 2017 at 1:36 PM, Ori Hoch ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In knesset_data/dataservice/bills.py
<#8 (comment)>
:
> +)
+import constants
+
+
+class Bill(BaseKnessetDataServiceCollectionObject):
+ SERVICE_NAME = "api"
+ METHOD_NAME = "KNS_Bill"
+ ORDERED_FIELDS = [
+ ("id", KnessetDataServiceSimpleField('BillID', "integer", "the primary key")),
+ ("kns_num", KnessetDataServiceSimpleField('KnessetNum', "integer", "kneset number")),
+ ("name", KnessetDataServiceSimpleField('Name', "string", "bill heb name")),
+ ("type_id", KnessetDataServiceSimpleField('SubTypeID', "integer", "type id of the bill")),
+ ("type_description",
+ KnessetDataServiceSimpleField('SubTypeDesc', "string", "type description of the bill")),
+ ("private_num", KnessetDataServiceSimpleField('PrivateNumber', "integer",)),
+ ("committee_id", KnessetDataServiceSimpleField('CommitteeID', "integer",)),
maybe it's worth to create a new class for this type of fields
something like:
("committee", KnessetdataServiceRelatedField("CommitteeID",
dataservice_class=Committee))
which will handle it automatically
but need to make sure by default it doesn't fetch the related object -
only when user requests it
so I'm not sure what's the best way to implement it..
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#8 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALLijYV8VlNJ9_XfNKniX6UrRjqdIuQpks5rriirgaJpZM4Mvc8c>
.
|
…into add-bills-dataservice
No description provided.