Skip to content

Commit

Permalink
Merge pull request #3 from duckduckgrayduck/main
Browse files Browse the repository at this point in the history
Fixes queries,
  • Loading branch information
cam-garrison authored Jan 3, 2024
2 parents 2844361 + b36c9d1 commit d9c3af7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
20 changes: 6 additions & 14 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -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

11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
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)))
return df

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)

Expand All @@ -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),
)

Expand Down

0 comments on commit d9c3af7

Please sign in to comment.