Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent activity #4568

Closed
Jegelewicz opened this issue Apr 15, 2022 · 4 comments
Closed

Agent activity #4568

Jegelewicz opened this issue Apr 15, 2022 · 4 comments
Labels
Function-Agents function-Reports Grant funded (Arctos) This issue is related to an Arctos grant funded project Priority-High (Needed for work) High because this is causing a delay in important collection work..

Comments

@Jegelewicz
Copy link
Member

@dustymc I'd like to get some SQL that I could give a list of agent preferred names and get back for each of them:

agent remark
birth date
death date
ORCiD address
Wikidata address
earliest collection date
latest collection date
a comma separated list of all collections they are active in (in any capacity: collector, determiner, transaction)

Really not that much... :-)

Maybe this is a report? I'm really just tired of all the clicking through individual agents for comparison with potential duplicates for incoming collections.

@Jegelewicz Jegelewicz added Priority-High (Needed for work) High because this is causing a delay in important collection work.. Function-Agents Grant funded (Arctos) This issue is related to an Arctos grant funded project function-Reports labels Apr 15, 2022
@dustymc dustymc added this to the Needs Discussion milestone Apr 15, 2022
@dustymc
Copy link
Contributor

dustymc commented Apr 15, 2022

Maybe this is a report?

Yea, SQL isn't a great tool for that, want to mark up the agent activity report?

@dustymc
Copy link
Contributor

dustymc commented May 5, 2022

From some meeting or something: summarize collector activity by collection and year (maybe even decade, need to see what's workable)

@dustymc dustymc changed the title SQL request - Agent activity Agent activity May 5, 2022
@dustymc
Copy link
Contributor

dustymc commented May 11, 2022

More detail in next release.

Here's some SQL @Jegelewicz - performance is not good and it's not all of what you asked for, probably the only realistic comprehensive approach would be to APIify the detail page.

select
    agent.agent_id,
    agent.preferred_agent_name,
    agent.agent_remarks,
    status.status_summary,
    addrs.addrs,
    mindate.earliest_date,
    maxdate.latest_date,
    allcolns.gps
from
    agent
    left outer join (
        select 
            agent_id,
            string_agg(ss,' | ') as status_summary from (
            select agent_id,concat(agent_status.agent_status,': ',agent_status.status_date) as ss 
            from agent_status
            ) x group by agent_id
    ) as status on agent.agent_id=status.agent_id
    left outer join (
        select agent_id, string_agg(concat_ws(': ',address_type,address),' | ') as addrs from address
        where address_type in ('ORCID','Library of Congress','Wikidata')
         group by agent_id
    ) as addrs on agent.agent_id=addrs.agent_id
    inner join (
        select collector.agent_id,min(began_date) as earliest_date
        from
        collector
        inner join specimen_event on collector.collection_object_id=specimen_event.collection_object_id
        inner join collecting_event on specimen_event.collecting_event_id=collecting_event.collecting_event_id
        group by collector.agent_id
    ) as mindate on agent.agent_id=mindate.agent_id
    inner join (
        select collector.agent_id,max(ended_date) as latest_date
        from
        collector
        inner join specimen_event on collector.collection_object_id=specimen_event.collection_object_id
        inner join collecting_event on specimen_event.collecting_event_id=collecting_event.collecting_event_id
        group by collector.agent_id
    ) as maxdate on agent.agent_id=maxdate.agent_id
    inner join (
        select
        agent_id,
        string_agg(guid_prefix,' | ') as gps
        from (select collector.agent_id,
            guid_prefix
            from
        collector
        inner join cataloged_item on collector.collection_object_id=cataloged_item.collection_object_id
        inner join collection on cataloged_item.collection_id=collection.collection_id
        group by collector.agent_id,guid_prefix
        order by guid_prefix
        ) x group by agent_id
    ) allcolns on agent.agent_id=allcolns.agent_id
where agent.agent_id in (21247816);

@Jegelewicz
Copy link
Member Author

@dustymc thanks! I hope you are feeling better! Can you help out Jessica with this? https://github.com/ArctosDB/data-migration/issues/1091#issuecomment-1076785641

@dustymc dustymc closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Function-Agents function-Reports Grant funded (Arctos) This issue is related to an Arctos grant funded project Priority-High (Needed for work) High because this is causing a delay in important collection work..
Projects
None yet
Development

No branches or pull requests

2 participants