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

Add avolpe/crowdfiller integration #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions portal/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {ActionResearchLanding} from './pages/ActionResearchLanding';
import {OCDSBuyersPage} from './pages/OCDSBuyers';
import {OCDSSupplierWithSanctionPage} from './pages/OCDSSupplierWithSanction';
import {OCDSCovidTenders} from './pages/OCDSCovidTenders';
import Banner from "./Home/Banner";
import {LandingPage} from "./pages/Landing";

export default function App() {
return <Routes/>
Expand Down Expand Up @@ -54,7 +54,7 @@ function Routes() {
<Route path="/action" exact render={() => <ActionResearchLanding/>}/>
<Route path="/explore" exact render={() => <Welcome/>}/>
<Route path="/">
<Banner/>
<LandingPage/>
</Route>
</Switch>
</QueryParamProvider>
Expand Down
90 changes: 0 additions & 90 deletions portal/src/Home/Banner.tsx

This file was deleted.

57 changes: 57 additions & 0 deletions portal/src/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,60 @@ export interface OCDSCovidTender {
id: string;
}>;
}

export interface GlobalStatistics {
current_year: number;
payed_salaries: number;
payed_salaries_month: string;
ocds_current_year_contracts: number;
ocds_covid_contracts: number;
calc_date: string
}

/**
* Represents a networks resource.
*
* Useful in switches and with pattern matching
*/
export type Async<T, E = Error> = {
state: 'NO_REQUESTED'
} | {
state: 'FETCHING'
} | {
state: 'LOADED',
data: T
} | {
state: 'ERROR',
error: E
}

/**
* A single helper to produce NetworkResource instances quickly
*/
export const AsyncHelper = {
noRequested: () => ({state: 'NO_REQUESTED' as const}),
fetching: () => ({state: 'FETCHING' as const}),
loaded: <T>(data: T) => ({state: 'LOADED' as const, data}),
error: <E>(error: E) => ({state: 'ERROR' as const, error}),

or: function <T, E>(nr: Async<T, E>, def: T) {
if (nr.state === 'LOADED') return nr.data;
return def;
},

map: function <T, E, K>(nr: Async<T, E>, mapper: (toMap: T) => K): Async<K, E> {
switch (nr.state) {
case 'ERROR':
return AsyncHelper.error(nr.error);
case 'FETCHING':
return AsyncHelper.fetching();
case 'LOADED':
const mapped: K = mapper(nr.data);
return AsyncHelper.loaded<K>(mapped);
case 'NO_REQUESTED':
default:
return AsyncHelper.noRequested();

}
}
};
11 changes: 8 additions & 3 deletions portal/src/RedashAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Affidavit,
AndeExonerated,
Authorities,
EssapExonerated,
EssapExonerated, GlobalStatistics,
OCDSBuyerWithAmount,
OCDSCovidTender,
OCDSItemRankingListRow,
Expand All @@ -13,7 +13,7 @@ import {
Supplier
} from './Model';

const BASE_API = "https://datapy.redash.cds.com.py/api";
const BASE_API = "https://redash.controlciudadanopy.org/api";

const API_KEYS: Record<number, string> = {
1: "Wtp9iNNTzO2yTbUwfoE4bOM7qd9msWnWIJ9aeatl",
Expand All @@ -25,7 +25,8 @@ const API_KEYS: Record<number, string> = {
28: "qMecN8ma9IkW2Tekpebk8ygk4c3fzzos2mk6ya0A",
35: "WYy6Jsk51sOOQuhzOwCriygodvlolhxwjyIxbpRH",
36: "vX16f20urPFfYsebawg3Kda9qhN6JDTCexhH8Trf",
37: "N0DHcr72NbiWC5n3IBEVmkSoViBxud8GTxKNLi3z"
37: "N0DHcr72NbiWC5n3IBEVmkSoViBxud8GTxKNLi3z",
39: "g74o1ujam75shxjB8BVJ1nOQkInbsrgpTax9sukM"
}


Expand Down Expand Up @@ -92,6 +93,10 @@ export class RedashAPI {
getCovidTenders(): Promise<BaseRedashResponse<OCDSCovidTender>> {
return this.fetchQuery(37);
}

getMainStatistics(): Promise<BaseRedashResponse<GlobalStatistics>> {
return this.fetchQuery(39)
}
}

interface BaseRedashResponse<T> {
Expand Down
2 changes: 1 addition & 1 deletion portal/src/SimpleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SimpleAPINotPaginatedResult
} from './Model';

const BASE_API = "https://datapy.cds.com.py/api";
const BASE_API = "https://api.controlciudadanopy.org/api";
//const BASE_API = "http://localhost:3001/api";

export class SimpleApi {
Expand Down
Loading