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

Fix #2394: Add docstring to core.domain.user_jobs_continous.py #3569

Merged
merged 9 commits into from
Jul 9, 2017

Conversation

shubha1593
Copy link
Contributor

Fix #2394 : Add docstring for the functions in proper format.

@shubha1593 shubha1593 requested a review from seanlip June 24, 2017 06:05
Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks, @shubha1593 -- this is a great start! Please see inline comments.

user_id: str. The unique ID of the user

Returns:
tuple(job_queued_msec, output):
Copy link
Member

Choose a reason for hiding this comment

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

tuple(float, list(dict)). A 2-tuple with the following entries:
- float. The time, in milliseconds since the Epoch, when the job was queued.
- list(dict). A list of ... with keys:
  - 'type': str. Either ...
  - 'activity_id': str. The ID of the ...
  - ...

Note, for the second arg, how the types of each key of the dict are specified. The descriptions for the other fields need to be completed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

type, such as feconf.UPDATE_TYPE_EXPLORATION_COMMIT.
delete_commit_message: This (string) represents the commit message
delete_commit_message: str. This represents the commit message
to use when an activity is found to be deleted, such as
feconf.COMMIT_MESSAGE_EXPLORATION_DELETED.

Returns:
A tuple with two entries:
Copy link
Member

Choose a reason for hiding this comment

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

See above for notes on format:

tuple(...). A tuple with two entries:
- ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Computes most recent activity commits and feedbacks of a spcecific user.

Args:
item: The parameter passed to this function is a single element of
Copy link
Member

Choose a reason for hiding this comment

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

Can we just say:

item: UserSubscriptionsModel. An instance of UserSubscriptionsModel.

Seems more concrete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


Returns:
This function may yield as many times as appropriate (including zero)
the key/value 2-tuples.
Copy link
Member

Choose a reason for hiding this comment

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

"the key/value 2-tuples. For example" --> "2-tuples in the format"

and combine into a single sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

For example, (reducer_key, recent_activity_commit_dict) where
reducer_key: str. This is of the form 'user_id@job_queued_msec'
recent_activity_commit_dict: dictionary with the following keys
- 'type': The value of the commit_type argument.
Copy link
Member

Choose a reason for hiding this comment

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

Please add type info (see above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Returns:
This function may yield as many times as appropriate the key/value 2-tuples.
For example, (id, exploration_data) where
id: str. The unique id of contributor or owner of the exploration
Copy link
Member

Choose a reason for hiding this comment

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

Reframe this so that it's more centered on the user, rather than on the exploration. E.g.:

id: str. A user ID.
exploration_data: dict. A dict that includes entries for all the explorations that this user contributes to or owns. Each entry has the following keys: ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- 'num_ratings_for_owned_exp': int. Total number of ratings for the
exploration
"""

Copy link
Member

Choose a reason for hiding this comment

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

Remove newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

stringified_values: A list of information regarding all the explorations
owned by user.
"""

Copy link
Member

Choose a reason for hiding this comment

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

Remove newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

of ratings across all explorations and average rating.

Args:
key: str. The unique id of user
Copy link
Member

Choose a reason for hiding this comment

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

Add period at end; ditto elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -520,6 +594,17 @@ def map(item):

@staticmethod
def reduce(key, stringified_values):
"""Implements the reduce function.
This function creates or updates the UserStatsModel instance for the given
Copy link
Member

Choose a reason for hiding this comment

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

Add newline above this one (since it's a new paragraph).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov-io
Copy link

codecov-io commented Jul 1, 2017

Codecov Report

Merging #3569 into develop will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3569      +/-   ##
===========================================
- Coverage    44.85%   44.84%   -0.01%     
===========================================
  Files          257      257              
  Lines        19871    19873       +2     
  Branches      3131     3132       +1     
===========================================
  Hits          8913     8913              
- Misses       10958    10960       +2
Impacted Files Coverage Δ
...ev/head/pages/exploration_editor/EditorServices.js 35.13% <0%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f904ee9...b9c21be. Read the comment docs.

@shubha1593 shubha1593 requested a review from seanlip July 1, 2017 15:04
Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @shubha1593! This is looking great; I've taken a first pass and made a few more notes, but they're mostly on small things. PTAL?


Returns:
tuple(float, list(dict)). A 2-tuple with following entries:
-float. The time, in milliseconds since the Epoch, when the job was queued.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: here and below, please add a single space after each "-".

-'activity_id': str. The ID of the exploration being committed to or
to which the feedback thread belongs.
-'activity_title': str. The title of the activity.
-'last_updated_ms': float. The time when the update was made.
Copy link
Member

Choose a reason for hiding this comment

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

The time when the update was made, in milliseconds since the Epoch.

-'activity_title': str. The title of the activity.
-'last_updated_ms': float. The time when the update was made.
-'author_id': str. The ID of the author who made the update.
-'subject': str. The commit message or message indicating a feedback
Copy link
Member

Choose a reason for hiding this comment

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

I think you can say: "A brief description of the notification." This automatically covers cases where additional notification types are added in the future.

was deleted.
- A list containing valid activity model instances which are
mappable to feedback threads
tuple(list(dict), list(*)). A 2-tuple with following entries:
Copy link
Member

Choose a reason for hiding this comment

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

Don't the elements of the second list have a specific type?

tuple(list(dict), list(ExplorationModel|...|...)).

(where you should enumerate the different classes that can occur in the second argument).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, do you want me to specify all the models in the argument ?
('activity', 'audit', 'base_model', 'classifier', 'collection', 'config',
'email', 'exploration', 'feedback', 'file', 'job', 'recommendations',
'statistics', 'user')

Copy link
Member

Choose a reason for hiding this comment

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

Nope, just the specific model classes that are processed in this job and that can appear in this tuple.

mappable to feedback threads
tuple(list(dict), list(*)). A 2-tuple with following entries:
-list(dict): A list, having information for every activity in
activity_ids_list. Dict have the following keys:
Copy link
Member

Choose a reason for hiding this comment

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

Dict have --> Each dict in this list has

- 'total_plays': # of times the user's explorations were played
- 'num_ratings': # of times the user's explorations were started
- 'average_ratings': average of average ratings across all explorations
'total_plays': int. # of times the user's explorations were played.
Copy link
Member

Choose a reason for hiding this comment

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

--> Number; ditto in next line.


Yields:
This function may yield as many times as appropriate 2-tuples in the
format: (str, dict) where
Copy link
Member

Choose a reason for hiding this comment

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

Ditto (see a previous comment) re punctuation.

-dict: A dict that includes entries for all the explorations that this
user contributes to or owns. Each entry has the following keys:
- 'exploration_impact_score': float. The impact score of all the
explorations contributed to by the user.
Copy link
Member

Choose a reason for hiding this comment

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

This should be indented by 4 from the previous line. Similarly below.


Args:
key: str. The unique ID of the user.
stringified_values: list(str(dict)). A list of information regarding all
Copy link
Member

Choose a reason for hiding this comment

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

See previous comment re type info.

the explorations that this user contributes to or owns. Each entry is
a stringified dict having the following keys:
- 'exploration_impact_score': float. The impact score of all the
explorations contributed to by the user.
Copy link
Member

Choose a reason for hiding this comment

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

Ditto re indentation.

@shubha1593 shubha1593 requested a review from seanlip July 5, 2017 06:09
@shubha1593
Copy link
Contributor Author

@seanlip made the modifications, please have a look.

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

This looks excellent, LGTM. Thank you, @shubha1593!

@seanlip
Copy link
Member

seanlip commented Jul 5, 2017

Or rather ... almost excellent. I'm afraid the lint checks fail; please take a look at the logs. (Did the lint checks not run automaticaly before you pushed?)

Assigning this to @AllanYangZhou to merge once the lint checks are fixed.

@AllanYangZhou
Copy link
Contributor

Hi @shubha1593, have you had a chance to look at the lint errors and correct them? Looks like the only issue is that some lines are too long, once that's fixed I can merge it in.

@shubha1593
Copy link
Contributor Author

Hi @AllanYangZhou, I am having issues with my machine, need to format it. I will fix the lint errors by today or tomorrow definitely.

@AllanYangZhou
Copy link
Contributor

Understood, thanks!

@shubha1593
Copy link
Contributor Author

Hi @AllanYangZhou, Fixed the lint errors.

@AllanYangZhou AllanYangZhou merged commit 8aab2a4 into oppia:develop Jul 9, 2017
@AllanYangZhou
Copy link
Contributor

Nice, thanks!

@shubha1593 shubha1593 deleted the update-docstring branch July 9, 2017 16:51
giritheja added a commit to giritheja/oppia that referenced this pull request Jul 16, 2017
…date

* upstream/develop: (32 commits)
  Remove erroneous clause in app.yaml. (oppia#3643)
  Part of oppia#2447: Upgrade select2 library (oppia#3626)
  Fix part of oppia#2394: Added docstrings in exp_domain.py (oppia#3578)
  Fix oppia#3618: stop icon overlap (oppia#3642)
  Add backend functionality to correctly handle needs_update part of subtitled HTML. (oppia#3620)
  Change 'style' to 'ng-attr-style' in an attempt to fix IE bug in collection viewer. (oppia#3636)
  Fix typo in Exploration editor (oppia#3637)
  Update credits (oppia#3633)
  Fix oppia#2639: Updated Google chart/visualization Library loader code and use async to load the library (oppia#3614)
  Fix user bios job in the case that user_bio is None (oppia#3632)
  Update changelog and credits for release 2.5.2 (oppia#3628)
  Fix oppia#2394: Add docstring to core.domain.user_jobs_continous.py (oppia#3569)
  Fix oppia#3585: Corrected arrows in exploration progress nav (oppia#3605)
  change the text
  edit error message
  Corrected tense of error message
  Corrected state to read card
  Close modal window if clicked outside (oppia#3623)
  Storage, Domain classes and helper functions for ClassifierExplorationMapping (oppia#3583)
  removed super admin role from admin interface. (oppia#3621)
  ...
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.

4 participants