Phate334 / community-monitor

0 stars 0 forks source link

Sweep: 將要查詢的類別取出放在陣列中 #1

Open Phate334 opened 1 year ago

Phate334 commented 1 year ago

monitor/main.py module 的 fetch_arxiv() 中目前只會搜尋 cs.AI 這個類別,我想先在外面用一個陣列儲存更多類別,並把函數改為逐一查詢後才輸出所有結果。

sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/Phate334/community-monitor/pull/3.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/Phate334/community-monitor/blob/cc3471f4b005a05642d59f1304f1a6856b767a56/monitor/main.py#L1-L54 https://github.com/Phate334/community-monitor/blob/cc3471f4b005a05642d59f1304f1a6856b767a56/README.md#L1-L19 https://github.com/Phate334/community-monitor/blob/cc3471f4b005a05642d59f1304f1a6856b767a56/monitor/db_manager.py#L1-L33 https://github.com/Phate334/community-monitor/blob/cc3471f4b005a05642d59f1304f1a6856b767a56/monitor/models/arxiv.py#L1-L13 https://github.com/Phate334/community-monitor/blob/cc3471f4b005a05642d59f1304f1a6856b767a56/monitor/config.py#L1-L17

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
monitor/main.py At the top of the file, define an array of categories that we want to search for. Modify the fetch_arxiv() function to iterate over this array and perform the search for each category. Ensure that the results of each search are appended to the articles list.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add support for searching multiple categories in fetch_arxiv() sweep/multiple-categories-search

Description

This PR adds support for searching multiple categories in the fetch_arxiv() function in monitor/main.py. Currently, the function only searches for articles in the cs.AI category. With this PR, we introduce an array of categories that can be searched, allowing for more flexibility in the search query.

Summary of Changes

  • Added an array of categories at the top of monitor/main.py to store the categories to be searched.
  • Modified the fetch_arxiv() function to iterate over the array of categories and perform the search for each category.
  • Appended the results of each search to the articles list, ensuring that all the results are returned by the function.

This PR addresses Issue #1.


Step 4: ⌨️ Coding

File Instructions Progress
monitor/main.py At the top of the file, define an array of categories that we want to search for. Modify the fetch_arxiv() function to iterate over this array and perform the search for each category. Ensure that the results of each search are appended to the articles list. ✅ Done with commit cc3471f I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are the my self-reviews of my changes at sweep/multiple-categories-search.

Here is the 1st review

Thanks for your contribution. The code is mostly correct, but there's a small improvement that could be made to enhance efficiency.

In monitor/main.py:

  • Please move the definition of today and yesterday variables outside the loop in the fetch_arxiv function (lines 22-23). These variables don't need to be redefined in each iteration of the loop.

Here's how you could modify the code:

today = datetime.today() - timedelta(days=2)  # UTC-5 timezone
yesterday = today - timedelta(days=1)
for category in categories:
    search = arxiv.Search(
        query=f"cat:{category} AND submittedDate:[{yesterday.strftime('%Y%m%d')} TO {today.strftime('%Y%m%d')}]",
        max_results=float("inf"),
    )
    ...

Keep up the good work!

I finished incorporating these changes.


To recreate the pull request, leave a comment prefixed with "sweep:" or edit the issue. Join Our Discord