granddebat.sh 23.9 KB
Newer Older
Code for France's avatar
Code for France committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#! /bin/bash

# dossier de destination des fichier json des propositions
DIR=proposals/$1
STEP=$(grep $1 themes.csv | sed 's/,.*$//')
CURSOR=null
TEMP=/tmp/out-$1.json

mkdir -p $DIR
rm id-$1.txt

TOTAL=$(curl -s 'https://granddebat.fr/graphql/internal' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0' -H 'Accept: application/json' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Referer: https://granddebat.fr/project/la-transition-ecologique/collect/participez-a-la-recherche-collective-de-solutions-1' -H 'content-type: application/json' -H 'origin: https://granddebat.fr' --data '{"operationName":"ProposalListViewPaginatedQuery","query":"query ProposalListViewPaginatedQuery(\n  $stepId: ID!\n  $cursor: String\n  $orderBy: ProposalOrder\n  $isAuthenticated: Boolean!\n  $count: Int\n  $term: String\n  $district: ID\n  $category: ID\n  $status: ID\n  $theme: ID\n  $userType: ID\n) {\n  step: node(id: $stepId) {\n    __typename\n    ...ProposalListViewPaginated_step\n    ...ProposalStepPageHeader_step\n    id\n  }\n}\n\nfragment ProposalListViewPaginated_step on ProposalStep {\n  id\n  ... on CollectStep {\n    private\n  }\n  ...ProposalList_step\n  proposals(first: $count, after: $cursor, orderBy: $orderBy, term: $term, district: $district, theme: $theme, category: $category, status: $status, userType: $userType) {\n    totalCount\n    ...ProposalList_proposals\n    edges {\n      node {\n        id\n        __typename\n      }\n      cursor\n    }\n    pageInfo {\n      hasPreviousPage\n      hasNextPage\n      startCursor\n      endCursor\n    }\n  }\n}\n\nfragment ProposalStepPageHeader_step on ProposalStep {\n  id\n  allProposals: proposals(first: 0) {\n    totalCount\n    fusionCount\n  }\n  proposals(first: $count, after: $cursor, orderBy: $orderBy, term: $term, district: $district, theme: $theme, category: $category, status: $status, userType: $userType) {\n    totalCount\n    edges {\n      node {\n        id\n        __typename\n      }\n      cursor\n    }\n    pageInfo {\n      endCursor\n      hasNextPage\n    }\n  }\n  ... on CollectStep {\n    kind\n    form {\n      id\n      isProposalForm\n      ...ProposalCreate_proposalForm\n    }\n    voteThreshold\n  }\n  ... on SelectionStep {\n    kind\n    form {\n      isProposalForm\n      id\n    }\n  }\n}\n\nfragment ProposalCreate_proposalForm on ProposalForm {\n  id\n  contribuable\n  isProposalForm\n  ...ProposalForm_proposalForm\n  ...ProposalCreateButton_proposalForm\n}\n\nfragment ProposalForm_proposalForm on ProposalForm {\n  id\n  description\n  suggestingSimilarProposals\n  step {\n    id\n  }\n  districts(order: ALPHABETICAL) {\n    id\n    name\n  }\n  categories(order: ALPHABETICAL) {\n    id\n    name\n  }\n  questions {\n    __typename\n    id\n    title\n    number\n    private\n    position\n    required\n    helpText\n    jumps {\n      id\n      always\n      origin {\n        __typename\n        id\n      }\n      destination {\n        __typename\n        id\n        title\n        number\n      }\n      conditions {\n        __typename\n        id\n        operator\n        question {\n          __typename\n          id\n          title\n        }\n        ... on MultipleChoiceQuestionLogicJumpCondition {\n          value {\n            id\n            title\n          }\n        }\n      }\n    }\n    description\n    type\n    ... on MultipleChoiceQuestion {\n      isOtherAllowed\n      randomQuestionChoices\n      validationRule {\n        type\n        number\n      }\n      choices(allowRandomize: true) {\n        id\n        title\n        description\n        color\n        image {\n          id\n          url\n        }\n      }\n    }\n  }\n  usingDistrict\n  districtMandatory\n  districtHelpText\n  usingThemes\n  themeMandatory\n  usingCategories\n  categoryMandatory\n  categoryHelpText\n  usingAddress\n  titleHelpText\n  summaryHelpText\n  themeHelpText\n  illustrationHelpText\n  descriptionHelpText\n  addressHelpText\n  proposalInAZoneRequired\n  isProposalForm\n  usingDescription\n  descriptionMandatory\n  usingSummary\n  usingIllustration\n}\n\nfragment ProposalCreateButton_proposalForm on ProposalForm {\n  isProposalForm\n}\n\nfragment ProposalList_step on ProposalStep {\n  id\n  ...ProposalListTable_step\n  ...ProposalPreview_step\n}\n\nfragment ProposalList_proposals on ProposalConnection {\n  ...ProposalListTable_proposals_2r3fA4\n  totalCount\n  edges {\n    node {\n      id\n      ...ProposalPreview_proposal_Q37Wz\n    }\n  }\n}\n\nfragment ProposalListTable_proposals_2r3fA4 on ProposalConnection {\n  edges {\n    node {\n      id\n      url\n      title\n      progressSteps {\n        title\n        startAt\n        endAt\n        ...ImplementationStepTitle_progressSteps\n        id\n      }\n      currentVotableStep {\n        __typename\n        title\n        id\n      }\n      status(step: $stepId) {\n        name\n        color\n        id\n      }\n      author {\n        displayName\n        url\n        media {\n          url\n          id\n        }\n        id\n      }\n      reference\n      district {\n        name\n        id\n      }\n      category {\n        name\n        id\n      }\n      theme {\n        title\n        id\n      }\n      estimation\n      likers {\n        displayName\n        id\n      }\n      updatedAt\n      publishedAt\n    }\n  }\n}\n\nfragment ProposalPreview_proposal_Q37Wz on Proposal {\n  id\n  author {\n    vip\n    id\n  }\n  ...ProposalPreviewHeader_proposal\n  ...ProposalPreviewFooter_proposal_2GsTBv\n  ...ProposalPreviewBody_proposal_m0K3u\n  ...ProposalStatus_proposal_2GsTBv\n}\n\nfragment ProposalPreviewHeader_proposal on Proposal {\n  ...UnpublishedLabel_publishable\n  publishedAt\n  createdAt\n  author {\n    id\n    displayName\n    url\n    media {\n      url\n      id\n    }\n  }\n}\n\nfragment ProposalPreviewFooter_proposal_2GsTBv on Proposal {\n  id\n  form {\n    commentable\n    id\n  }\n  commentsCount\n  allVotesOnStep: votes(stepId: $stepId, first: 0) {\n    totalCount\n  }\n}\n\nfragment ProposalPreviewBody_proposal_m0K3u on Proposal {\n  id\n  title\n  trashed\n  trashedStatus\n  url\n  summaryOrBodyExcerpt\n  district {\n    name\n    id\n  }\n  theme {\n    title\n    id\n  }\n  category {\n    name\n    id\n  }\n  ...ProposalPreviewVote_proposal_39ngnn\n  ...ProposalDetailEstimation_proposal\n  ...ProposalDetailLikers_proposal\n  ...ProposalVoteThresholdProgressBar_proposal\n  currentVotableStep {\n    __typename\n    id\n  }\n  ...ProposalFollowButton_proposal_39ngnn\n}\n\nfragment ProposalStatus_proposal_2GsTBv on Proposal {\n  trashed\n  trashedStatus\n  status(step: $stepId) {\n    name\n    color\n    id\n  }\n}\n\nfragment ProposalPreviewVote_proposal_39ngnn on Proposal {\n  id\n  ...ProposalVoteModal_proposal_2r3fA4 @include(if: $isAuthenticated)\n  ...ProposalVoteButtonWrapperFragment_proposal_Q37Wz\n}\n\nfragment ProposalDetailEstimation_proposal on Proposal {\n  estimation\n}\n\nfragment ProposalDetailLikers_proposal on Proposal {\n  id\n  likers {\n    id\n  }\n  ...ProposalDetailLikersLabel_proposal\n  ...ProposalDetailLikersModal_proposal\n}\n\nfragment ProposalVoteThresholdProgressBar_proposal on Proposal {\n  id\n  votes(stepId: $stepId, first: 0) {\n    totalCount\n  }\n}\n\nfragment ProposalFollowButton_proposal_39ngnn on Proposal {\n  id\n  viewerIsFollowing @include(if: $isAuthenticated)\n  viewerFollowingConfiguration @include(if: $isAuthenticated)\n}\n\nfragment ProposalDetailLikersLabel_proposal on Proposal {\n  id\n  likers {\n    id\n  }\n}\n\nfragment ProposalDetailLikersModal_proposal on Proposal {\n  id\n  likers {\n    id\n    displayName\n    biography\n    url\n    username\n    vip\n    media {\n      url\n      id\n    }\n  }\n}\n\nfragment ProposalVoteModal_proposal_2r3fA4 on Proposal {\n  id\n  viewerHasVote(step: $stepId)\n}\n\nfragment ProposalVoteButtonWrapperFragment_proposal_Q37Wz on Proposal {\n  id\n  estimation\n  viewerHasVote(step: $stepId) @include(if: $isAuthenticated)\n  ...ProposalVoteButton_proposal_Q37Wz\n}\n\nfragment ProposalVoteButton_proposal_Q37Wz on Proposal {\n  id\n  viewerHasVote(step: $stepId) @include(if: $isAuthenticated)\n  viewerVote(step: $stepId) @include(if: $isAuthenticated) {\n    id\n    ...UnpublishedTooltip_publishable\n  }\n}\n\nfragment UnpublishedTooltip_publishable on Publishable {\n  id\n  published\n  notPublishedReason\n}\n\nfragment UnpublishedLabel_publishable on Publishable {\n  id\n  published\n  notPublishedReason\n  publishableUntil\n}\n\nfragment ImplementationStepTitle_progressSteps on ProgressStep {\n  id\n  title\n  startAt\n  endAt\n}\n\nfragment ProposalListTable_step on ProposalStep {\n  form {\n    usingThemes\n    usingDistrict\n    usingCategories\n    usingDescription\n    usingSummary\n    descriptionMandatory\n    isProposalForm\n    id\n  }\n}\n\nfragment ProposalPreview_step on Step {\n  ...ProposalPreviewBody_step\n  ...ProposalPreviewFooter_step\n}\n\nfragment ProposalPreviewBody_step on ProposalStep {\n  id\n  ...ProposalPreviewVote_step_39ngnn\n  ...ProposalVoteThresholdProgressBar_step\n  voteThreshold\n  voteType\n  project {\n    opinionCanBeFollowed\n    id\n  }\n}\n\nfragment ProposalPreviewFooter_step on ProposalStep {\n  voteType\n}\n\nfragment ProposalPreviewVote_step_39ngnn on Step {\n  ...ProposalVoteModal_step_39ngnn\n  ...ProposalVoteButtonWrapperFragment_step\n}\n\nfragment ProposalVoteThresholdProgressBar_step on Step {\n  id\n  ... on CollectStep {\n    voteThreshold\n  }\n  ... on SelectionStep {\n    voteThreshold\n  }\n}\n\nfragment ProposalVoteModal_step_39ngnn on ProposalStep {\n  id\n  votesRanking\n  votesHelpText\n  ... on RequirementStep {\n    requirements {\n      viewerMeetsTheRequirements @include(if: $isAuthenticated)\n      reason\n      totalCount\n    }\n  }\n  form {\n    isProposalForm\n    id\n  }\n  ...RequirementsForm_step_39ngnn\n  ...ProposalsUserVotesTable_step\n  viewerVotes(orderBy: {field: POSITION, direction: ASC}) @include(if: $isAuthenticated) {\n    ...ProposalsUserVotesTable_votes\n    totalCount\n    edges {\n      node {\n        id\n      }\n    }\n  }\n}\n\nfragment ProposalVoteButtonWrapperFragment_step on ProposalStep {\n  id\n  title\n  votesLimit\n  voteType\n  open\n  ...VoteButtonOverlay_step\n}\n\nfragment VoteButtonOverlay_step on ProposalStep {\n  id\n  votesLimit\n}\n\nfragment RequirementsForm_step_39ngnn on RequirementStep {\n  requirements {\n    edges {\n      node {\n        __typename\n        id\n        viewerMeetsTheRequirement @include(if: $isAuthenticated)\n        ... on DateOfBirthRequirement {\n          viewerDateOfBirth @include(if: $isAuthenticated)\n        }\n        ... on FirstnameRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on LastnameRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on PhoneRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on CheckboxRequirement {\n          label\n        }\n      }\n    }\n  }\n}\n\nfragment ProposalsUserVotesTable_step on ProposalStep {\n  id\n  votesRanking\n  ...ProposalUserVoteItem_step\n}\n\nfragment ProposalsUserVotesTable_votes on ProposalVoteConnection {\n  edges {\n    node {\n      id\n      ...ProposalUserVoteItem_vote\n      anonymous\n      proposal {\n        id\n        title\n      }\n    }\n  }\n}\n\nfragment ProposalUserVoteItem_vote on ProposalVote {\n  ...UnpublishedLabel_publishable\n  published\n  createdAt\n  proposal {\n    id\n    title\n    url\n    ...ProposalDetailEstimation_proposal\n  }\n}\n\nfragment ProposalUserVoteItem_step on ProposalStep {\n  id\n  open\n  voteType\n  votesRanking\n}\n","variables":{"stepId":"'$STEP'","cursor":"'$CURS'","orderBy":{"field":"PUBLISHED_AT","direction":"ASC"},"isAuthenticated":false,"count":100,"term":null,"district":null,"category":null,"status":null,"theme":null,"userType":null}}' | jq .data.step.allProposals.totalCount)
NB=100
PAGES=$(echo "$TOTAL / $NB" | bc)

for n in $(seq 0 $PAGES)
do
    echo -n "$1 $n/$PAGES $CURS "
    curl -s 'https://granddebat.fr/graphql/internal' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0' -H 'Accept: application/json' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Referer: https://granddebat.fr/project/la-transition-ecologique/collect/participez-a-la-recherche-collective-de-solutions-1' -H 'content-type: application/json' -H 'origin: https://granddebat.fr' --data '{"operationName":"ProposalListViewPaginatedQuery","query":"query ProposalListViewPaginatedQuery(\n  $stepId: ID!\n  $cursor: String\n  $orderBy: ProposalOrder\n  $isAuthenticated: Boolean!\n  $count: Int\n  $term: String\n  $district: ID\n  $category: ID\n  $status: ID\n  $theme: ID\n  $userType: ID\n) {\n  step: node(id: $stepId) {\n    __typename\n    ...ProposalListViewPaginated_step\n    ...ProposalStepPageHeader_step\n    id\n  }\n}\n\nfragment ProposalListViewPaginated_step on ProposalStep {\n  id\n  ... on CollectStep {\n    private\n  }\n  ...ProposalList_step\n  proposals(first: $count, after: $cursor, orderBy: $orderBy, term: $term, district: $district, theme: $theme, category: $category, status: $status, userType: $userType) {\n    totalCount\n    ...ProposalList_proposals\n    edges {\n      node {\n        id\n        __typename\n      }\n      cursor\n    }\n    pageInfo {\n      hasPreviousPage\n      hasNextPage\n      startCursor\n      endCursor\n    }\n  }\n}\n\nfragment ProposalStepPageHeader_step on ProposalStep {\n  id\n  allProposals: proposals(first: 0) {\n    totalCount\n    fusionCount\n  }\n  proposals(first: $count, after: $cursor, orderBy: $orderBy, term: $term, district: $district, theme: $theme, category: $category, status: $status, userType: $userType) {\n    totalCount\n    edges {\n      node {\n        id\n        __typename\n      }\n      cursor\n    }\n    pageInfo {\n      endCursor\n      hasNextPage\n    }\n  }\n  ... on CollectStep {\n    kind\n    form {\n      id\n      isProposalForm\n      ...ProposalCreate_proposalForm\n    }\n    voteThreshold\n  }\n  ... on SelectionStep {\n    kind\n    form {\n      isProposalForm\n      id\n    }\n  }\n}\n\nfragment ProposalCreate_proposalForm on ProposalForm {\n  id\n  contribuable\n  isProposalForm\n  ...ProposalForm_proposalForm\n  ...ProposalCreateButton_proposalForm\n}\n\nfragment ProposalForm_proposalForm on ProposalForm {\n  id\n  description\n  suggestingSimilarProposals\n  step {\n    id\n  }\n  districts(order: ALPHABETICAL) {\n    id\n    name\n  }\n  categories(order: ALPHABETICAL) {\n    id\n    name\n  }\n  questions {\n    __typename\n    id\n    title\n    number\n    private\n    position\n    required\n    helpText\n    jumps {\n      id\n      always\n      origin {\n        __typename\n        id\n      }\n      destination {\n        __typename\n        id\n        title\n        number\n      }\n      conditions {\n        __typename\n        id\n        operator\n        question {\n          __typename\n          id\n          title\n        }\n        ... on MultipleChoiceQuestionLogicJumpCondition {\n          value {\n            id\n            title\n          }\n        }\n      }\n    }\n    description\n    type\n    ... on MultipleChoiceQuestion {\n      isOtherAllowed\n      randomQuestionChoices\n      validationRule {\n        type\n        number\n      }\n      choices(allowRandomize: true) {\n        id\n        title\n        description\n        color\n        image {\n          id\n          url\n        }\n      }\n    }\n  }\n  usingDistrict\n  districtMandatory\n  districtHelpText\n  usingThemes\n  themeMandatory\n  usingCategories\n  categoryMandatory\n  categoryHelpText\n  usingAddress\n  titleHelpText\n  summaryHelpText\n  themeHelpText\n  illustrationHelpText\n  descriptionHelpText\n  addressHelpText\n  proposalInAZoneRequired\n  isProposalForm\n  usingDescription\n  descriptionMandatory\n  usingSummary\n  usingIllustration\n}\n\nfragment ProposalCreateButton_proposalForm on ProposalForm {\n  isProposalForm\n}\n\nfragment ProposalList_step on ProposalStep {\n  id\n  ...ProposalListTable_step\n  ...ProposalPreview_step\n}\n\nfragment ProposalList_proposals on ProposalConnection {\n  ...ProposalListTable_proposals_2r3fA4\n  totalCount\n  edges {\n    node {\n      id\n      ...ProposalPreview_proposal_Q37Wz\n    }\n  }\n}\n\nfragment ProposalListTable_proposals_2r3fA4 on ProposalConnection {\n  edges {\n    node {\n      id\n      url\n      title\n      progressSteps {\n        title\n        startAt\n        endAt\n        ...ImplementationStepTitle_progressSteps\n        id\n      }\n      currentVotableStep {\n        __typename\n        title\n        id\n      }\n      status(step: $stepId) {\n        name\n        color\n        id\n      }\n      author {\n        displayName\n        url\n        media {\n          url\n          id\n        }\n        id\n      }\n      reference\n      district {\n        name\n        id\n      }\n      category {\n        name\n        id\n      }\n      theme {\n        title\n        id\n      }\n      estimation\n      likers {\n        displayName\n        id\n      }\n      updatedAt\n      publishedAt\n    }\n  }\n}\n\nfragment ProposalPreview_proposal_Q37Wz on Proposal {\n  id\n  author {\n    vip\n    id\n  }\n  ...ProposalPreviewHeader_proposal\n  ...ProposalPreviewFooter_proposal_2GsTBv\n  ...ProposalPreviewBody_proposal_m0K3u\n  ...ProposalStatus_proposal_2GsTBv\n}\n\nfragment ProposalPreviewHeader_proposal on Proposal {\n  ...UnpublishedLabel_publishable\n  publishedAt\n  createdAt\n  author {\n    id\n    displayName\n    url\n    media {\n      url\n      id\n    }\n  }\n}\n\nfragment ProposalPreviewFooter_proposal_2GsTBv on Proposal {\n  id\n  form {\n    commentable\n    id\n  }\n  commentsCount\n  allVotesOnStep: votes(stepId: $stepId, first: 0) {\n    totalCount\n  }\n}\n\nfragment ProposalPreviewBody_proposal_m0K3u on Proposal {\n  id\n  title\n  trashed\n  trashedStatus\n  url\n  summaryOrBodyExcerpt\n  district {\n    name\n    id\n  }\n  theme {\n    title\n    id\n  }\n  category {\n    name\n    id\n  }\n  ...ProposalPreviewVote_proposal_39ngnn\n  ...ProposalDetailEstimation_proposal\n  ...ProposalDetailLikers_proposal\n  ...ProposalVoteThresholdProgressBar_proposal\n  currentVotableStep {\n    __typename\n    id\n  }\n  ...ProposalFollowButton_proposal_39ngnn\n}\n\nfragment ProposalStatus_proposal_2GsTBv on Proposal {\n  trashed\n  trashedStatus\n  status(step: $stepId) {\n    name\n    color\n    id\n  }\n}\n\nfragment ProposalPreviewVote_proposal_39ngnn on Proposal {\n  id\n  ...ProposalVoteModal_proposal_2r3fA4 @include(if: $isAuthenticated)\n  ...ProposalVoteButtonWrapperFragment_proposal_Q37Wz\n}\n\nfragment ProposalDetailEstimation_proposal on Proposal {\n  estimation\n}\n\nfragment ProposalDetailLikers_proposal on Proposal {\n  id\n  likers {\n    id\n  }\n  ...ProposalDetailLikersLabel_proposal\n  ...ProposalDetailLikersModal_proposal\n}\n\nfragment ProposalVoteThresholdProgressBar_proposal on Proposal {\n  id\n  votes(stepId: $stepId, first: 0) {\n    totalCount\n  }\n}\n\nfragment ProposalFollowButton_proposal_39ngnn on Proposal {\n  id\n  viewerIsFollowing @include(if: $isAuthenticated)\n  viewerFollowingConfiguration @include(if: $isAuthenticated)\n}\n\nfragment ProposalDetailLikersLabel_proposal on Proposal {\n  id\n  likers {\n    id\n  }\n}\n\nfragment ProposalDetailLikersModal_proposal on Proposal {\n  id\n  likers {\n    id\n    displayName\n    biography\n    url\n    username\n    vip\n    media {\n      url\n      id\n    }\n  }\n}\n\nfragment ProposalVoteModal_proposal_2r3fA4 on Proposal {\n  id\n  viewerHasVote(step: $stepId)\n}\n\nfragment ProposalVoteButtonWrapperFragment_proposal_Q37Wz on Proposal {\n  id\n  estimation\n  viewerHasVote(step: $stepId) @include(if: $isAuthenticated)\n  ...ProposalVoteButton_proposal_Q37Wz\n}\n\nfragment ProposalVoteButton_proposal_Q37Wz on Proposal {\n  id\n  viewerHasVote(step: $stepId) @include(if: $isAuthenticated)\n  viewerVote(step: $stepId) @include(if: $isAuthenticated) {\n    id\n    ...UnpublishedTooltip_publishable\n  }\n}\n\nfragment UnpublishedTooltip_publishable on Publishable {\n  id\n  published\n  notPublishedReason\n}\n\nfragment UnpublishedLabel_publishable on Publishable {\n  id\n  published\n  notPublishedReason\n  publishableUntil\n}\n\nfragment ImplementationStepTitle_progressSteps on ProgressStep {\n  id\n  title\n  startAt\n  endAt\n}\n\nfragment ProposalListTable_step on ProposalStep {\n  form {\n    usingThemes\n    usingDistrict\n    usingCategories\n    usingDescription\n    usingSummary\n    descriptionMandatory\n    isProposalForm\n    id\n  }\n}\n\nfragment ProposalPreview_step on Step {\n  ...ProposalPreviewBody_step\n  ...ProposalPreviewFooter_step\n}\n\nfragment ProposalPreviewBody_step on ProposalStep {\n  id\n  ...ProposalPreviewVote_step_39ngnn\n  ...ProposalVoteThresholdProgressBar_step\n  voteThreshold\n  voteType\n  project {\n    opinionCanBeFollowed\n    id\n  }\n}\n\nfragment ProposalPreviewFooter_step on ProposalStep {\n  voteType\n}\n\nfragment ProposalPreviewVote_step_39ngnn on Step {\n  ...ProposalVoteModal_step_39ngnn\n  ...ProposalVoteButtonWrapperFragment_step\n}\n\nfragment ProposalVoteThresholdProgressBar_step on Step {\n  id\n  ... on CollectStep {\n    voteThreshold\n  }\n  ... on SelectionStep {\n    voteThreshold\n  }\n}\n\nfragment ProposalVoteModal_step_39ngnn on ProposalStep {\n  id\n  votesRanking\n  votesHelpText\n  ... on RequirementStep {\n    requirements {\n      viewerMeetsTheRequirements @include(if: $isAuthenticated)\n      reason\n      totalCount\n    }\n  }\n  form {\n    isProposalForm\n    id\n  }\n  ...RequirementsForm_step_39ngnn\n  ...ProposalsUserVotesTable_step\n  viewerVotes(orderBy: {field: POSITION, direction: ASC}) @include(if: $isAuthenticated) {\n    ...ProposalsUserVotesTable_votes\n    totalCount\n    edges {\n      node {\n        id\n      }\n    }\n  }\n}\n\nfragment ProposalVoteButtonWrapperFragment_step on ProposalStep {\n  id\n  title\n  votesLimit\n  voteType\n  open\n  ...VoteButtonOverlay_step\n}\n\nfragment VoteButtonOverlay_step on ProposalStep {\n  id\n  votesLimit\n}\n\nfragment RequirementsForm_step_39ngnn on RequirementStep {\n  requirements {\n    edges {\n      node {\n        __typename\n        id\n        viewerMeetsTheRequirement @include(if: $isAuthenticated)\n        ... on DateOfBirthRequirement {\n          viewerDateOfBirth @include(if: $isAuthenticated)\n        }\n        ... on FirstnameRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on LastnameRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on PhoneRequirement {\n          viewerValue @include(if: $isAuthenticated)\n        }\n        ... on CheckboxRequirement {\n          label\n        }\n      }\n    }\n  }\n}\n\nfragment ProposalsUserVotesTable_step on ProposalStep {\n  id\n  votesRanking\n  ...ProposalUserVoteItem_step\n}\n\nfragment ProposalsUserVotesTable_votes on ProposalVoteConnection {\n  edges {\n    node {\n      id\n      ...ProposalUserVoteItem_vote\n      anonymous\n      proposal {\n        id\n        title\n      }\n    }\n  }\n}\n\nfragment ProposalUserVoteItem_vote on ProposalVote {\n  ...UnpublishedLabel_publishable\n  published\n  createdAt\n  proposal {\n    id\n    title\n    url\n    ...ProposalDetailEstimation_proposal\n  }\n}\n\nfragment ProposalUserVoteItem_step on ProposalStep {\n  id\n  open\n  voteType\n  votesRanking\n}\n","variables":{"stepId":"'$STEP'","cursor":"'$CURS'","orderBy":{"field":"PUBLISHED_AT","direction":"DESC"},"isAuthenticated":false,"count":'$NB',"term":null,"district":null,"category":null,"status":null,"theme":null,"userType":null}}' \
    | jq . > $TEMP  || cat $TEMP
    CURS=$(jq -r .data.step.proposals.pageInfo.endCursor $TEMP)
    jq .data.step.proposals.edges[].node.id -r $TEMP >> id-$1.txt
    for p in $(jq .data.step.proposals.edges[].node.id -r $TEMP)
    do
        if [ ! -e "$DIR/$p.json" ]
        then
            echo -n '.'
            sh granddebat_proposal.sh $p > $DIR/$p.json
        fi
    done
    echo ''
    rm $TEMP
done