Skip to content

discrepancy between project progress #603

Open
@Hagellach37

Description

@Hagellach37

The project progress calculation reveals different results for different parts of the mapswipe code.

During transfer results we use this function: https://github.com/mapswipe/python-mapswipe-workers/blob/master/mapswipe_workers/mapswipe_workers/firebase_to_postgres/update_data.py#L570

In generate stats we use another function: https://github.com/mapswipe/python-mapswipe-workers/blob/master/mapswipe_workers/mapswipe_workers/generate_stats/project_stats_by_date.py#L8

For the project -NFNr55R_LYJvxP7wmte the transfer results gives us 100% whereas we get 94.74% for the generate stats workflow.

This is the query in transfer results:

select
 avg(group_progress)::integer as progress
 from
        (
            -- Get all groups for this project and
    -- add progress for groups that have been worked on already.
    -- Set progress to 0 if no user has worked on this group.
    -- For groups that no users worked on
    -- there are no entries in the results table.
    select
      g.group_id
      ,g.project_id
      ,case
        when group_progress is null then 0
        else group_progress
      end as group_progress
    from groups g
    left join
        (
        -- Here we get the progress for all groups
        -- for which results have been submitted already.
        -- Progress for a group can be max 100
        -- even if more users than required submitted results.
        -- The verification number of a project is used here.
        select
          ms.group_id
          ,ms.project_id
          ,case
            when count(distinct user_id) >= p.verification_number then 100
            else 100 * count(distinct user_id) / p.verification_number
          end as group_progress
        from mapping_sessions ms, projects p
        where ms.project_id = p.project_id
        group by group_id, ms.project_id, p.verification_number
    ) bar
    on bar.group_id = g.group_id and bar.project_id = g.project_id
    where g.project_id = '-NFNr55R_LYJvxP7wmte'
) foo
group by project_id 

It seems that the code in generate stats is not giving the correct results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions