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

発表用媒体(PDF, etc)を返すエンドポイントを作成 #183

Closed
17 tasks done
Cj-bc opened this issue Sep 9, 2018 · 17 comments
Closed
17 tasks done

発表用媒体(PDF, etc)を返すエンドポイントを作成 #183

Cj-bc opened this issue Sep 9, 2018 · 17 comments
Assignees
Labels
enhancement New feature or request epic Something big immediate Immediate action is requested

Comments

@Cj-bc
Copy link
Member

Cj-bc commented Sep 9, 2018

Step 1: 目的

  • 発表用に印刷するファイルを作成し、返す

Step 2: 概要

  • 仕様: 一個前のtime_indexの各lotteryのwinnersのpublic_idを、classroomごとにわけ、かつその中でstudent/visitorで分けて印刷可能にしたものを返す。作成した媒体はキャッシュする。

  • 既に作成されている場合は、キャッシュされたものを返す

  • エンドポイント名は、PDFという文字列を含まないもの

  • rfc: /results -- 権限範囲 rfcs#2

タスク:

  • 返す形式を決定(PDF or html)

  • PDF or HTMLのテンプレートを作成する(おそらくjinja)

    • html部分の作成
    • css部分の作成
  • エンドポイント名を決定

  • 権限範囲決定 ( /results -- 権限範囲 rfcs#2)

  • spec作成

  • エンドポイントを作成

    • 1. Get previous time index
    • 2. Get previous lotteries using index
    • 5. Make 2 public_id lists, based on user's 'kind'('student', 'visitor')
    • 6. Send them to the jinja template
  • get_prev_time_index追加

  • test作成

    • test: test_prev_time_index_ooa
    • test: test_prev_time_index_lim
    • test: test_prev_time_index_same

決定事項:

  • 形式: PDF HTML(システムの都合上PDF化は時間がかかりそうでした)
  • PDFを出力する: pdfkit
  • エンドポイント名: /render_results
  • HTTP method: GET
  • 権限制約: なし
  • 時間外だった場合のエラーコードおよびstatus code
    • error_code: 06
    • HTTP status code: 400
    • error_message: not acceptable time
@Cj-bc Cj-bc added enhancement New feature or request immediate Immediate action is requested epic Something big labels Sep 9, 2018
@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 9, 2018

FlaskでPDFを返す方法: https://aroundthedistance.hatenadiary.jp/entry/2015/01/18/234425

@Cj-bc Cj-bc self-assigned this Sep 10, 2018
@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

HTTP method: GET
path: /results

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

rfc has been opened Sakuten/rfcs#2

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

権限範囲は決定しないことになりました。

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

時間外だった場合のエラーコードおよびstatus code
error_code: 06
HTTP status code: 404
error_message: not acceptable time

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

get_prev_time_index仕様

  • あるindexの応募受付時間終了時+1分〜次回の応募受付時間終了時+1分までの間、そのindexを返します

@coord-e
Copy link
Contributor

coord-e commented Sep 10, 2018

時間外、400では?

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 10, 2018

あ、ほんとだww
単純なミスですありがと

Cj-bc added a commit that referenced this issue Sep 10, 2018
…us time index

This method would work like this:

|-- TIME_POINTS[0]
|
|             |-- TIME_POINTS[1]
|             |
|             ||-- TIMEPOINT_END_MARGIN
|             ||
|             ||   |-- DRAWWING_TIME EXTENSION
|             ||   |
|             ||   |       |-- Void time (annoucements, the show is going...)
|             ||   |       |
v  index: x   vv   v       v          index: y                      index: z
|=============|-|******|         |=============|-|******|         |=============|-|
              |++++++++++++++++++++++++++++++++|
                                               |________________________________|

In the range of |+|, `get_prev_time_index` will return `x`.
In the range of |_|, `get_prev_time_index` will return `y`.
@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 11, 2018

template作成について

  • 横に並べられるIDの数はいくつか
  • kindで分けて発表とあるが、紙を分けて発表するという認識で合っているか

@Cj-bc

This comment has been minimized.

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 11, 2018

データ構造的によろしくないかもしれませんが、ちょっと進ませてくだせぇ..

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 11, 2018

配列の分け方、リファクタリングが必要な部分です。

data = {'kinds':                                                         
          [{'visitor':                                                   
              [{'classroom_id': lottery.classroom_id,                    
                'winners': [lottery.application.user(has 'visitor' kind)]
               }],                                                       
            'student':                                                   
              [{'classroom_id': lottery.classroom_id,                    
                'winners': [lottery.application.user(has 'student' kind)]
               }]                                                        
           }]                                                            
       }                                                                 

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 11, 2018

PDFきつそうなので一度HTMLで返します
PDFきつい理由: wkhtmltopdfが、alpine上でcss適用がうまくできないという情報を取得したから
参考:
https://gist.github.com/akihiromukae/288b163d538d45a197b3f1b54ef385e8

PDFで返すissueも立てておきますが、first_release後になる可能性があります

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 12, 2018

又、HTMLに変更したことにより、cacheを持つ必要も無くなったので、cache関連のtodoを削除します

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 12, 2018

🤔
あとはcss書けば終わりです

Cj-bc added a commit that referenced this issue Sep 12, 2018
The diagram on the commit message was wrong,
so DON'T PREFER TO IT.
Instead, see notes.
you can show notes by using:
```
git notes show 3fb5c1a
```
Cj-bc added a commit that referenced this issue Sep 12, 2018
…dex'

Test whether it fail when the time is out of acceptable range
Cj-bc added a commit that referenced this issue Sep 12, 2018
…e edge of range

If I do `ends[i] <= time <= ends[i+1]`,
This expression will be True twice when `time` is the same as
`ends[i+1]` because that would be the same as `ends[i] for the
next expression.

Of cource, this conflict won't work because of looping,
But it is not good idea to leave things confusing, right?
So I fixed it
Cj-bc added a commit that referenced this issue Sep 12, 2018
Cj-bc added a commit that referenced this issue Sep 12, 2018
Cj-bc added a commit that referenced this issue Sep 12, 2018
Cj-bc added a commit that referenced this issue Sep 12, 2018
it's because the way generating PDF could be hard to do in such a
limited time.
I found that wkhtmltopdf doesn't treat CSS on alpine.
It'll take more times to solve
@shino16
Copy link
Member

shino16 commented Sep 14, 2018

A0サイズををCSSで表現するとき
仕様では841mmですが、それだとはみ出ます
適正サイズはフォントサイズによって変わるようです
小さめに調整します

@Cj-bc
Copy link
Member Author

Cj-bc commented Sep 15, 2018

close with merging of #212

@Cj-bc Cj-bc closed this as completed Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request epic Something big immediate Immediate action is requested
Projects
None yet
Development

No branches or pull requests

3 participants