project Utilities / File Location Listing avatar

utilities/file_location_listing#56: Count only mode throws AttributeError: 'int' object has no attribute 'get'



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.2.7
Created: 02-Jun-24 21:41



Description

Just had the following exception thrown

  File "/app/server/server.py", line 61, in search
    "results" : dosearch.search(srchterm, search_type, limit, count_only)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server/../lib/dosearch.py", line 281, in search
    results.sort(reverse=True, key=lambda x: x.get("last-mod-s", 0))
  File "/app/server/../lib/dosearch.py", line 281, in <lambda>
    results.sort(reverse=True, key=lambda x: x.get("last-mod-s", 0))
                                             ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'get'


Toggle State Changes

Activity


assigned to @btasker

That part of the code is supposed to be sorting results in reverse chronographical order.

However, my search won't have returned results - it's a count-only search:

curl -v -d '{"term":"linux", "type": "DOC", "count-only": true}'

During a count-only search, the search threads will return a list containing a single entry: the count.

verified

mentioned in commit 015c0f6fc2f470de7d8cbb25187659c045be86ce

Commit: 015c0f6fc2f470de7d8cbb25187659c045be86ce 
Author: B Tasker                            
                            
Date: 2024-06-02T22:46:37.000+01:00 

Message

fix: don't try to sort results in count-only mode (utilities/file_location_listing#56)

+6 -6 (12 lines changed)

changed title from AttributeError: 'int' object has no attribute 'get' to {+Count only mode throws +}AttributeError: 'int' object has no attribute 'get'