Another batch of renaming Record to Data
This commit is contained in:
parent
e827789a09
commit
16089ea5b2
61 changed files with 283 additions and 441 deletions
|
|
@ -107,7 +107,7 @@ class NotionListPages(CustomComponent):
|
|||
response.raise_for_status()
|
||||
|
||||
results = response.json()
|
||||
records = []
|
||||
data = []
|
||||
combined_text = f"Pages found: {len(results['results'])}\n\n"
|
||||
for page in results['results']:
|
||||
page_data = {
|
||||
|
|
@ -127,10 +127,10 @@ class NotionListPages(CustomComponent):
|
|||
)
|
||||
|
||||
combined_text += text
|
||||
records.append(Data(text=text, data=page_data))
|
||||
data.append(Data(text=text, data=page_data))
|
||||
|
||||
self.status = combined_text.strip()
|
||||
return records
|
||||
return data
|
||||
|
||||
except Exception as e:
|
||||
self.status = f"An error occurred: {str(e)}"
|
||||
|
|
|
|||
|
|
@ -65,14 +65,14 @@ class NotionUserList(CustomComponent):
|
|||
data = response.json()
|
||||
results = data['results']
|
||||
|
||||
records = []
|
||||
data = []
|
||||
for user in results:
|
||||
id = user['id']
|
||||
type = user['type']
|
||||
name = user.get('name', '')
|
||||
avatar_url = user.get('avatar_url', '')
|
||||
|
||||
record_data = {
|
||||
data_dict = {
|
||||
"id": id,
|
||||
"type": type,
|
||||
"name": name,
|
||||
|
|
@ -80,15 +80,15 @@ class NotionUserList(CustomComponent):
|
|||
}
|
||||
|
||||
output = "User:\n"
|
||||
for key, value in record_data.items():
|
||||
for key, value in data_dict.items():
|
||||
output += f"{key.replace('_', ' ').title()}: {value}\n"
|
||||
output += "________________________\n"
|
||||
|
||||
record = Data(text=output, data=record_data)
|
||||
records.append(record)
|
||||
record = Data(text=output, data=data_dict)
|
||||
data.append(record)
|
||||
|
||||
self.status = "\n".join(record.text for record in records)
|
||||
return records
|
||||
self.status = "\n".join(record.text for record in data)
|
||||
return data
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class NotionSearch(CustomComponent):
|
|||
response.raise_for_status()
|
||||
|
||||
results = response.json()
|
||||
records = []
|
||||
data = []
|
||||
combined_text = f"Results found: {len(results['results'])}\n\n"
|
||||
for result in results['results']:
|
||||
result_data = {
|
||||
|
|
@ -135,10 +135,10 @@ class NotionSearch(CustomComponent):
|
|||
|
||||
text += f"type: {result['object']}\nlast_edited_time: {result['last_edited_time']}\n\n"
|
||||
combined_text += text
|
||||
records.append(Data(text=text, data=result_data))
|
||||
data.append(Data(text=text, data=result_data))
|
||||
|
||||
self.status = combined_text
|
||||
return records
|
||||
return data
|
||||
|
||||
except Exception as e:
|
||||
self.status = f"An error occurred: {str(e)}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue