Skip to content

Commit

Permalink
stats-updater: Only store oldestdate at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Aug 19, 2024
1 parent 1dbd980 commit 8302d8d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
1 change: 0 additions & 1 deletion apps/stats-updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ COPY apps/stats-updater/bundle.mjs /app/
COPY packages/prisma-schemas/client_coa/ /client_coa
COPY packages/prisma-schemas/client_dm/ /client_dm
COPY packages/prisma-schemas/client_dm_stats/ /client_dm_stats
COPY packages/prisma-schemas/client_dm_stats_new/ /client_dm_stats_new
COPY packages/prisma-schemas/schemas/dm_stats/migrations/0_init/migration.sql /dm-stats-ddl.sql

EXPOSE 3000
Expand Down
19 changes: 8 additions & 11 deletions apps/stats-updater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ for (const envKey of [
}
}


process.env.DATABASE_URL_DM_STATS = process.env.DATABASE_URL_DM_STATS!.replace(
"dm_stats",
"dm_stats_new",
Expand Down Expand Up @@ -129,11 +128,9 @@ connect().then(async () => {
await prismaDmStats.storyIssue.createMany({
data: await prismaCoa.$queryRaw<
(Pick<inducks_storyversion, "storycode"> &
Pick<inducks_issue, "issuecode" | "oldestdate">)[]
Pick<inducks_issue, "issuecode">)[]
>`
select distinct sv.storycode,
i.issuecode,
i.oldestdate
select distinct sv.storycode, i.issuecode
from inducks_storyjob sj
inner join inducks_storyversion sv using (storyversioncode)
inner join inducks_entry e using (storyversioncode)
Expand Down Expand Up @@ -189,12 +186,11 @@ connect().then(async () => {

console.log("Creating missingIssueForUser entries");
await prismaDmStats.$executeRaw`
insert into utilisateurs_publications_manquantes(ID_User, personcode, storycode, issuecode, oldestdate, Notation)
insert into utilisateurs_publications_manquantes(ID_User, personcode, storycode, issuecode, Notation)
select distinct u_h_m.ID_User AS userId,
u_h_m.personcode,
u_h_m.storycode,
h_p.issuecode,
h_p.oldestdate,
a_p.Notation AS notation
from utilisateurs_histoires_manquantes u_h_m
inner join histoires_publications h_p using (storycode)
Expand All @@ -205,18 +201,19 @@ connect().then(async () => {
console.log("Creating suggestedIssueForUser entries");
await prismaDmStats.$executeRaw`
insert into utilisateurs_publications_suggerees(ID_User, issuecode, oldestdate, Score)
select ID_User AS userId, issuecode, oldestdate, sum(Notation) AS score
select ID_User AS userId, issuecode, '0000-00-00', sum(Notation) AS score
from utilisateurs_publications_manquantes
group by ID_User, issuecode, oldestdate`;
group by ID_User, issuecode`;

await prismaDmStats.$executeRaw`OPTIMIZE TABLE utilisateurs_publications_suggerees`;

console.log("Adding publicationcode and issuenumber for WTD < 3");
console.log("Adding oldestdate; adding publicationcode and issuenumber for WTD < 3");
await runQuery(`
UPDATE ${dbName}_new.utilisateurs_publications_suggerees
JOIN coa.inducks_issue i using (issuecode)
SET utilisateurs_publications_suggerees.publicationcode = i.publicationcode
, utilisateurs_publications_suggerees.issuenumber = i.issuenumber`);
, utilisateurs_publications_suggerees.issuenumber = i.issuenumber
, utilisateurs_publications_suggerees.oldestdate = i.oldestdate`);


await runQuery(`DROP DATABASE IF EXISTS ${dbName}_old`);
Expand Down
2 changes: 1 addition & 1 deletion apps/stats-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Daily stats calculation for DucksManager",
"main": "index.ts",
"scripts": {
"build": "bun build --target bun --sourcemap index.ts --outfile bundle.mjs && SCHEMA='dm_stats' DATABASE_URL_DM_STATS=`sed 's/dm_stats/dm_stats_new/g' $DATABASE_URL_DM_STATS` pnpm -r -F '~prisma-clients' prisma-generate"
"build": "bun build --target bun --sourcemap index.ts --outfile bundle.mjs"
},
"dependencies": {
"dotenv": "^16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion apps/whattheduck/android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ include ':capawesome-capacitor-file-picker'
project(':capawesome-capacitor-file-picker').projectDir = new File('../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capawesome/capacitor-file-picker/android')

include ':capgo-capacitor-updater'
project(':capgo-capacitor-updater').projectDir = new File('../node_modules/.pnpm/@capgo+capacitor-updater@6.0.56_@[email protected]/node_modules/@capgo/capacitor-updater/android')
project(':capgo-capacitor-updater').projectDir = new File('../node_modules/.pnpm/@capgo+capacitor-updater@6.1.0_@[email protected]/node_modules/@capgo/capacitor-updater/android')
2 changes: 1 addition & 1 deletion apps/whattheduck/ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def capacitor_pods
pod 'CapacitorPreferences', :path => '../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/preferences'
pod 'CapacitorStatusBar', :path => '../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar'
pod 'CapawesomeCapacitorFilePicker', :path => '../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capawesome/capacitor-file-picker'
pod 'CapgoCapacitorUpdater', :path => '../../node_modules/.pnpm/@capgo+capacitor-updater@6.0.56_@[email protected]/node_modules/@capgo/capacitor-updater'
pod 'CapgoCapacitorUpdater', :path => '../../node_modules/.pnpm/@capgo+capacitor-updater@6.1.0_@[email protected]/node_modules/@capgo/capacitor-updater'
end

target 'App' do
Expand Down
16 changes: 11 additions & 5 deletions apps/whattheduck/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ PODS:
- Capacitor
- CapawesomeCapacitorFilePicker (6.0.1):
- Capacitor
- CapgoCapacitorUpdater (6.0.56):
- CapgoCapacitorUpdater (6.1.0):
- Alamofire
- Capacitor
- SSZipArchive
- SwiftyRSA
- Version
- SQLCipher (4.6.0):
- SQLCipher/standard (= 4.6.0)
- SQLCipher/common (4.6.0)
- SQLCipher/standard (4.6.0):
- SQLCipher/common
- SSZipArchive (2.4.3)
- SwiftyRSA (1.7.0):
- SwiftyRSA/ObjC (= 1.7.0)
- SwiftyRSA/ObjC (1.7.0)
- Version (0.8.0)
- ZIPFoundation (0.9.19)

Expand All @@ -52,13 +56,14 @@ DEPENDENCIES:
- "CapacitorPreferences (from `../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/preferences`)"
- "CapacitorStatusBar (from `../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar`)"
- "CapawesomeCapacitorFilePicker (from `../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capawesome/capacitor-file-picker`)"
- "CapgoCapacitorUpdater (from `../../node_modules/.pnpm/@capgo+capacitor-updater@6.0.56_@[email protected]/node_modules/@capgo/capacitor-updater`)"
- "CapgoCapacitorUpdater (from `../../node_modules/.pnpm/@capgo+capacitor-updater@6.1.0_@[email protected]/node_modules/@capgo/capacitor-updater`)"

SPEC REPOS:
trunk:
- Alamofire
- SQLCipher
- SSZipArchive
- SwiftyRSA
- Version
- ZIPFoundation

Expand Down Expand Up @@ -88,7 +93,7 @@ EXTERNAL SOURCES:
CapawesomeCapacitorFilePicker:
:path: "../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capawesome/capacitor-file-picker"
CapgoCapacitorUpdater:
:path: "../../node_modules/.pnpm/@capgo+capacitor-updater@6.0.56_@[email protected]/node_modules/@capgo/capacitor-updater"
:path: "../../node_modules/.pnpm/@capgo+capacitor-updater@6.1.0_@[email protected]/node_modules/@capgo/capacitor-updater"

SPEC CHECKSUMS:
Alamofire: f36a35757af4587d8e4f4bfa223ad10be2422b8c
Expand All @@ -104,12 +109,13 @@ SPEC CHECKSUMS:
CapacitorPreferences: e8284bf740cf8c6d3f25409af3c01df87dfeb5a1
CapacitorStatusBar: b81d4fb5d4e0064c712018071b3ab4b810b39a63
CapawesomeCapacitorFilePicker: c80c30759ba48986ff34a2b51b23ac2babfd3774
CapgoCapacitorUpdater: 68b02356624ca2d34054d72e7b28ce58a1cc7c7d
CapgoCapacitorUpdater: dfe4b49cfc661f2cb78e93e953eda3663063f836
SQLCipher: 30a8e81afa6128e600b17ffa77d0f92fa05ed208
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
SwiftyRSA: 8c6dd1ea7db1b8dc4fb517a202f88bb1354bc2c6
Version: de5907f2c5d0f3cf21708db7801d1d5401139486
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c

PODFILE CHECKSUM: e5e4134b4adea0799f8c8c30043d78a0876bc749
PODFILE CHECKSUM: d70f912f9b7ab7c250a222b9e860a3b950ab97fa

COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion apps/whattheduck/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ion-page v-show="token === null">
<ion-header :translucent="true">
<ion-toolbar>
<ion-title class="ion-no-padding">{{ t('Connexion') }}</ion-title>
<ion-title class="ion-padding-start">{{ t('Connexion') }}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
Expand Down

0 comments on commit 8302d8d

Please sign in to comment.