diff --git a/config.yaml b/config.yaml index 0591c2f..fd7098a 100644 --- a/config.yaml +++ b/config.yaml @@ -1,22 +1,14 @@ -# The title is the title of your Add-On title: User Upload Frequency Graph -# The description will be shown above the form when activating the Add-On -description: This add-on will generate a graph of user upload frequency. -# Add-On specific instructions here. Optional +description: This add-on will generate a graph that shows the upload frequency for a particular user. instructions: '' -# Type should always be object type: object -# How does this add-on accept documents -# If more than one type is specified, the user will be prompted to choose one documents: [] -# Properties are the fields for your form properties: - # the key is the name of the variable that will be returned to your code - name: - # the title is what will be shown as the form label - title: Username - # a string is text - type: string + user_id: + title: User ID + type: integer +required: + - user_id categories: - statistical diff --git a/main.py b/main.py index 0a26d6b..bf6df60 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ class UploadGraph(AddOn): def create_df(self, doc_dates): df = pd.DataFrame(doc_dates, columns=["datetime"]) - df["datetime"] = df["datetime"].astype("datetime64") + df["datetime"] = pd.to_datetime(df["datetime"]).dt.tz_localize(None) df["date"] = df["datetime"].dt.date df = df.sort_values(by="date") df.insert(0, "count", range(1, 1 + len(df))) @@ -19,9 +19,10 @@ def create_df(self, doc_dates): def main(self): # fetch your add-on specific data - username = self.data.get("name", "world") - - query = "+user:" + username + user_id = self.data.get("user_id") + user = self.client.users.get(user_id) + user_name = user.username + query = "+user:" + str(user_id) documents = self.client.documents.search(query) @@ -35,7 +36,7 @@ def main(self): y="count", kind="line", x="date", - title=username + ": Uploads Over Time", + title=user_name + ": Uploads Over Time", figsize=(12, 8), )